結果
問題 | No.316 もっと刺激的なFizzBuzzをください |
ユーザー | kongarishisyamo |
提出日時 | 2016-02-24 03:44:19 |
言語 | C++11 (gcc 11.4.0) |
結果 |
WA
|
実行時間 | - |
コード長 | 614 bytes |
コンパイル時間 | 462 ms |
コンパイル使用メモリ | 58,456 KB |
実行使用メモリ | 4,348 KB |
最終ジャッジ日時 | 2023-10-23 19:33:19 |
合計ジャッジ時間 | 1,553 ms |
ジャッジサーバーID (参考情報) |
judge14 / judge12 |
(要ログイン)
テストケース
テストケース表示入力 | 結果 | 実行時間 実行使用メモリ |
---|---|---|
testcase_00 | WA | - |
testcase_01 | WA | - |
testcase_02 | AC | 2 ms
4,348 KB |
testcase_03 | AC | 2 ms
4,348 KB |
testcase_04 | WA | - |
testcase_05 | AC | 2 ms
4,348 KB |
testcase_06 | AC | 1 ms
4,348 KB |
testcase_07 | WA | - |
testcase_08 | AC | 2 ms
4,348 KB |
testcase_09 | AC | 2 ms
4,348 KB |
testcase_10 | AC | 2 ms
4,348 KB |
testcase_11 | WA | - |
testcase_12 | WA | - |
testcase_13 | WA | - |
testcase_14 | WA | - |
testcase_15 | WA | - |
testcase_16 | WA | - |
testcase_17 | WA | - |
testcase_18 | WA | - |
testcase_19 | WA | - |
testcase_20 | WA | - |
testcase_21 | WA | - |
testcase_22 | WA | - |
testcase_23 | WA | - |
testcase_24 | WA | - |
testcase_25 | WA | - |
testcase_26 | WA | - |
testcase_27 | AC | 2 ms
4,348 KB |
testcase_28 | AC | 2 ms
4,348 KB |
testcase_29 | WA | - |
testcase_30 | WA | - |
testcase_31 | AC | 1 ms
4,348 KB |
testcase_32 | WA | - |
testcase_33 | WA | - |
testcase_34 | WA | - |
testcase_35 | WA | - |
testcase_36 | WA | - |
ソースコード
#include<iostream> #include<algorithm> using namespace std; long long gcd(long long a,long long b){ if(a<b) return gcd(b,a); if(a%b==0) return b; return gcd(b,a%b); } int main(){ long long N,a,b,c; bool f=false; cin>>N>>a>>b>>c; if(a==1||b==1||c==1){ cout<<N<<endl; return 0; } if(a%b==0||a%c){ swap(a,c); f=true; } else if(b%a==0||b%c){ swap(b,c); f=true; } else if(c%b==0||c%a){ f=true; } if(b>c) swap(b,c); if(a>c) swap(a,c); long long ab=a*b/gcd(a,b); long long tmp=N/a+N/b-N/ab; if(!f){ for(int i=c;i<N;i+=c){ if(i%a!=0&&i%b!=0) tmp++; } } cout<<tmp<<endl; }