結果
問題 | No.982 Add |
ユーザー |
|
提出日時 | 2020-02-11 13:42:12 |
言語 | C++14 (gcc 11.2.0 + boost 1.78.0) |
結果 |
AC
|
実行時間 | 2 ms / 2,000 ms |
コード長 | 976 bytes |
コンパイル時間 | 653 ms |
使用メモリ | 3,900 KB |
最終ジャッジ日時 | 2022-11-24 17:24:18 |
合計ジャッジ時間 | 2,077 ms |
ジャッジサーバーID (参考情報) |
judge12 / judge11 |
テストケース
テストケース表示入力 | 結果 | 実行時間 使用メモリ |
---|---|---|
testcase_00 | AC | 2 ms
3,716 KB |
testcase_01 | AC | 2 ms
3,744 KB |
testcase_02 | AC | 2 ms
3,740 KB |
testcase_03 | AC | 2 ms
3,708 KB |
testcase_04 | AC | 2 ms
3,708 KB |
testcase_05 | AC | 2 ms
3,900 KB |
testcase_06 | AC | 2 ms
3,704 KB |
testcase_07 | AC | 2 ms
3,840 KB |
testcase_08 | AC | 2 ms
3,832 KB |
testcase_09 | AC | 2 ms
3,712 KB |
testcase_10 | AC | 2 ms
3,748 KB |
testcase_11 | AC | 2 ms
3,704 KB |
testcase_12 | AC | 2 ms
3,832 KB |
testcase_13 | AC | 2 ms
3,720 KB |
testcase_14 | AC | 1 ms
3,840 KB |
testcase_15 | AC | 2 ms
3,752 KB |
testcase_16 | AC | 2 ms
3,824 KB |
testcase_17 | AC | 2 ms
3,860 KB |
testcase_18 | AC | 1 ms
3,828 KB |
testcase_19 | AC | 2 ms
3,828 KB |
testcase_20 | AC | 2 ms
3,848 KB |
testcase_21 | AC | 2 ms
3,760 KB |
testcase_22 | AC | 2 ms
3,712 KB |
testcase_23 | AC | 1 ms
3,852 KB |
testcase_24 | AC | 2 ms
3,744 KB |
testcase_25 | AC | 2 ms
3,716 KB |
ソースコード
#include<iostream> #include<string> #include<iomanip> #include<cmath> #include<vector> #include<algorithm> using namespace std; #define int long long #define endl "\n" constexpr long long INF = (long long)1e18; constexpr long long MOD = 1'000'000'007; string yn(bool f){return f?"Yes":"No";} string YN(bool f){return f?"YES":"NO";} signed main(){ cin.tie(nullptr); ios::sync_with_stdio(false); cout<<fixed<<setprecision(10); const int MAX = 110000; int A, B, con = 0, LCM; vector<int> hoge(MAX); cin>>A>>B; // LCM = A/__gcd(A,B) * B; hoge[0] = true; for(int i = 0; i < MAX; i++){ if(hoge[i] == true && i + A < MAX) hoge[i + A] = true; } for(int i = 0; i < MAX; i++){ if(hoge[i] == true && i + B < MAX) hoge[i + B] = true; } for(int i = 1; i < MAX; i++){ if(!hoge[i]) con++; } // for(int i = 0; i < 500; i++){ // cout<<"i = "<<i<<" "<<hoge[i]<<endl; // } if(__gcd(A,B) == 1)cout<<con<<endl; else cout<<-1<<endl; return 0; }