結果
| 問題 | No.316 もっと刺激的なFizzBuzzをください |
| コンテスト | |
| ユーザー |
sasa
|
| 提出日時 | 2025-03-19 15:08:59 |
| 言語 | C++14 (gcc 13.3.0 + boost 1.87.0) |
| 結果 |
AC
|
| 実行時間 | 1 ms / 1,000 ms |
| コード長 | 628 bytes |
| コンパイル時間 | 345 ms |
| コンパイル使用メモリ | 27,904 KB |
| 実行使用メモリ | 7,328 KB |
| 最終ジャッジ日時 | 2025-03-19 15:09:01 |
| 合計ジャッジ時間 | 1,488 ms |
|
ジャッジサーバーID (参考情報) |
judge1 / judge2 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 4 |
| other | AC * 33 |
コンパイルメッセージ
main.cpp: In function ‘int main()’:
main.cpp:20:14: warning: ignoring return value of ‘int scanf(const char*, ...)’ declared with attribute ‘warn_unused_result’ [-Wunused-result]
20 | scanf("%lld",&val);
| ~~~~~^~~~~~~~~~~~~
main.cpp:23:14: warning: ignoring return value of ‘int scanf(const char*, ...)’ declared with attribute ‘warn_unused_result’ [-Wunused-result]
23 | scanf("%lld%lld%lld",&A, &B, &C);
| ~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~
ソースコード
#include <stdio.h>
// 最大公約数を求める関数
long gcd(long long a, long long b) {
while (b != 0) {
long long temp = b;
b = a % b;
a = temp;
}
return a;
}
// 最小公倍数を求める関数
long lcm(long long a, long long b) {
return (a * b) / gcd(a, b);
}
int main(void){
long long val = 0;
scanf("%lld",&val);
long long A, B, C;
scanf("%lld%lld%lld",&A, &B, &C);
long long ans = 0;
ans += val / A;
ans += val / B;
ans += val / C;
ans -= val / lcm(A,B);
ans -= val / lcm(B,C);
ans -= val / lcm(C,A);
ans += val / lcm(lcm(C,A),B);
printf("%lld",ans);
}
sasa