結果
| 問題 |
No.747 循環小数N桁目 Hard
|
| コンテスト | |
| ユーザー |
|
| 提出日時 | 2018-10-19 23:25:28 |
| 言語 | C++14 (gcc 13.3.0 + boost 1.87.0) |
| 結果 |
AC
|
| 実行時間 | 6 ms / 2,000 ms |
| コード長 | 496 bytes |
| コンパイル時間 | 573 ms |
| コンパイル使用メモリ | 65,592 KB |
| 実行使用メモリ | 5,248 KB |
| 最終ジャッジ日時 | 2024-11-18 22:40:42 |
| 合計ジャッジ時間 | 3,708 ms |
|
ジャッジサーバーID (参考情報) |
judge5 / judge3 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 4 |
| other | AC * 120 |
コンパイルメッセージ
main.cpp:5:1: warning: ISO C++ forbids declaration of 'main' with no type [-Wreturn-type]
5 | main()
| ^~~~
ソースコード
#include<iostream>
using namespace std;
string N,K;
int ans[]={4,2,8,5,7,1},n;
main()
{
cin>>N>>K;
for(int i=0;i<N.size();i++)n=(n*4+N[i]-'0')%6;
char k=K[K.size()-1];
bool flag=0;
if(k=='0'||k=='2'||k=='4'||k=='6'||k=='8')flag=1;
if(n==0)
{
cout<<ans[0]<<endl;
}
else if(n==1)
{
cout<<ans[1]<<endl;
}
else if(n==2)
{
cout<<ans[flag?4:2]<<endl;
}
else if(n==3)
{
cout<<ans[3]<<endl;
}
else if(n==4)
{
cout<<ans[4]<<endl;
}
else
{
cout<<ans[flag?1:5]<<endl;
}
}