結果
| 問題 | 
                            No.747 循環小数N桁目 Hard
                             | 
                    
| コンテスト | |
| ユーザー | 
                             | 
                    
| 提出日時 | 2021-08-04 16:28:44 | 
| 言語 | C++14  (gcc 13.3.0 + boost 1.87.0)  | 
                    
| 結果 | 
                             
                                WA
                                 
                             
                            
                         | 
                    
| 実行時間 | - | 
| コード長 | 784 bytes | 
| コンパイル時間 | 1,429 ms | 
| コンパイル使用メモリ | 168,244 KB | 
| 実行使用メモリ | 5,376 KB | 
| 最終ジャッジ日時 | 2024-09-16 15:09:04 | 
| 合計ジャッジ時間 | 5,029 ms | 
| 
                            ジャッジサーバーID (参考情報)  | 
                        judge1 / judge3 | 
(要ログイン)
| ファイルパターン | 結果 | 
|---|---|
| sample | WA * 4 | 
| other | WA * 120 | 
ソースコード
//#include <atcoder/all>
#include <bits/stdc++.h>
#include <cmath>
using namespace std;
//using namespace atcoder;
using ll = long long;
#define all(A) A.begin(),A.end()
using vll = vector<ll>;
#define rep(i, n) for (long long i = 0; i < (long long)(n); i++)
using Graph = vector<vector<ll>>;
int main() {
	string S="285714";
	
	string N;
	cin>>N;
	bool T=((N[N.size()-1]-'0')%2==0);
	ll Th=0;
	rep(i,N.size()){
		Th+=N[i]-'0';
		Th%=3;
	}
	string K;
	cin>>K;
	K="0"+K;
	ll f=(K[K.size()-2]-'0')*10+K[K.size()-1]-'0';
	f%=4;
	ll s=0;
	if(T){
		if(Th==0){
			s=0;
		}
		else if(Th==1){
			s=4;
		}
		else{
			s=2;
		}
	}
	else{
		if(Th==0){
			s=3;
		}
		else if(Th==1){
			s=1;
		}
		else{
			s=5;
		}
	}
	cout<<s<<endl;
	ll num=pow(s,f);
	num+=5;
	num%=6;
	cout<<S[num]<<endl;
}