結果
| 問題 |
No.316 もっと刺激的なFizzBuzzをください
|
| コンテスト | |
| ユーザー |
FF256grhy
|
| 提出日時 | 2015-12-09 15:56:27 |
| 言語 | C++11(廃止可能性あり) (gcc 13.3.0) |
| 結果 |
AC
|
| 実行時間 | 1 ms / 1,000 ms |
| コード長 | 524 bytes |
| コンパイル時間 | 186 ms |
| コンパイル使用メモリ | 23,296 KB |
| 実行使用メモリ | 6,820 KB |
| 最終ジャッジ日時 | 2024-11-21 11:32:42 |
| 合計ジャッジ時間 | 1,264 ms |
|
ジャッジサーバーID (参考情報) |
judge3 / judge4 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 4 |
| other | AC * 33 |
コンパイルメッセージ
main.cpp: In function ‘long long int gcd(long long int, long long int)’:
main.cpp:8:1: warning: control reaches end of non-void function [-Wreturn-type]
8 | }
| ^
main.cpp: In function ‘int main()’:
main.cpp:16:14: warning: ignoring return value of ‘int scanf(const char*, ...)’ declared with attribute ‘warn_unused_result’ [-Wunused-result]
16 | scanf("%lld%lld%lld%lld", &n, &a, &b, &c);
| ~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
ソースコード
#include <stdio.h>
long long int gcd(long long int x, long long int y) {
long long int i, z = (x < y ? x : y);
for(i = z; 0 < i; i--) {
if(x % i == 0 && y % i == 0) { return i; }
}
}
long long int lcm(long long int x, long long int y) {
return ( x / gcd(x, y) ) * y;
}
int main(void) {
long long int n, a, b, c;
scanf("%lld%lld%lld%lld", &n, &a, &b, &c);
long long int v = n/a + n/b + n/c;
v -= n / lcm(a, b) + n / lcm(b, c) + n / lcm(c, a);
v += n / lcm( lcm(a, b), c);
printf("%lld\n", v);
return 0;
}
FF256grhy