結果
問題 | No.316 もっと刺激的なFizzBuzzをください |
ユーザー |
![]() |
提出日時 | 2015-12-21 20:53:05 |
言語 | C++11 (gcc 13.3.0) |
結果 |
AC
|
実行時間 | 1 ms / 1,000 ms |
コード長 | 375 bytes |
コンパイル時間 | 279 ms |
コンパイル使用メモリ | 34,248 KB |
実行使用メモリ | 5,248 KB |
最終ジャッジ日時 | 2024-11-21 12:13:49 |
合計ジャッジ時間 | 1,344 ms |
ジャッジサーバーID (参考情報) |
judge4 / judge2 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 4 |
other | AC * 33 |
コンパイルメッセージ
main.cpp: In function ‘int main()’: main.cpp:15:14: warning: ignoring return value of ‘int scanf(const char*, ...)’ declared with attribute ‘warn_unused_result’ [-Wunused-result] 15 | scanf("%lld%lld%lld%lld",&n,&a,&b,&c); | ~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
ソースコード
#include<stdio.h> #include<algorithm> using namespace std; long long gcd(long long a,long long b){ while(a){ b%=a;long long c=a;a=b;b=c; } return b; } long long lcm(long long a,long long b){ return a/gcd(a,b)*b; } int main(){ long long n,a,b,c; scanf("%lld%lld%lld%lld",&n,&a,&b,&c); printf("%lld\n",n/a+n/b+n/c-n/lcm(a,b)-n/lcm(b,c)-n/lcm(a,c)+n/lcm(a,lcm(b,c))); }