結果
問題 | No.25 有限小数 |
ユーザー |
![]() |
提出日時 | 2022-08-16 13:53:57 |
言語 | C++23 (gcc 13.3.0 + boost 1.87.0) |
結果 |
WA
|
実行時間 | - |
コード長 | 1,179 bytes |
コンパイル時間 | 2,528 ms |
コンパイル使用メモリ | 247,124 KB |
実行使用メモリ | 6,820 KB |
最終ジャッジ日時 | 2024-10-03 05:07:30 |
合計ジャッジ時間 | 3,568 ms |
ジャッジサーバーID (参考情報) |
judge3 / judge1 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
other | AC * 21 WA * 10 |
ソースコード
#include <bits/stdc++.h>#define ll long long#define ld long double#define rep(i,a,b) for (int i = a; i < b; i++)#define irep(i,a,b) for (int i = a; i > b; i--)#define print(n) cout << n << endl#define rup(a,b) (a+b-1)/busing namespace std;unsigned ll gcd(unsigned ll a,unsigned ll b){if (a<b){swap(a,b);}if (b==0) return a;return gcd(b,a%b);}int main(){cout << fixed << setprecision(15);unsigned ll N,M;cin>>N>>M;unsigned ll d;bool p = false;while(true){if (M==1) break;d = gcd(N,M);//cout<<N<<" "<<M<<" "<<d<<endl;if (d==1){if (!p){p = true;N *= 10;continue;}else{break;}}N /= d;M /= d;p = false;continue;}if (M == 1){string s = to_string(N);char now = '1';rep(i,0,s.size()){if (s[i]=='0'){continue;}now = s[i];}print(now);}else{print(-1);}//system("pause");return 0;}