結果
問題 |
No.25 有限小数
|
ユーザー |
|
提出日時 | 2016-08-31 10:06:38 |
言語 | C++11(廃止可能性あり) (gcc 13.3.0) |
結果 |
WA
|
実行時間 | - |
コード長 | 790 bytes |
コンパイル時間 | 674 ms |
コンパイル使用メモリ | 65,168 KB |
実行使用メモリ | 6,824 KB |
最終ジャッジ日時 | 2024-11-14 12:53:38 |
合計ジャッジ時間 | 1,732 ms |
ジャッジサーバーID (参考情報) |
judge4 / judge5 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
other | AC * 11 WA * 20 |
ソースコード
#include <iostream> #include <iomanip> #include <limits> #include <string> #include <cstdio> using namespace std; typedef long long ll; string to_string2(double val){ char buff[numeric_limits<double>::max_exponent10+15+3]; sprintf(buff,"%.15f",val); return buff; } int main(){ ll n,m; cin>>n; cin>>m; int y=-1; if(n%m==0){ int x=n/m; string s=to_string(x); for(ll i=s.size()-1; i>=0; --i){ char a=s[i]; if(a!='0'){ y=a-'0'; break; } } } else { double x=n; x/=m; string s=to_string2(x); for(ll i=s.size()-1; i>0; --i){ char a=s[i]; if(a=='0'){ char b=s[i-1]; if(b!='0' && b!='.'){ y=b-'0'; break; } } } } cout<<y<<endl; return 0; }