結果

問題 No.434 占い
ユーザー 👑 kmjpkmjp
提出日時 2016-10-14 23:41:35
言語 C++11
(gcc 11.4.0)
結果
WA  
実行時間 -
コード長 1,389 bytes
コンパイル時間 1,659 ms
コンパイル使用メモリ 164,044 KB
実行使用メモリ 6,944 KB
最終ジャッジ日時 2024-05-01 23:09:49
合計ジャッジ時間 3,733 ms
ジャッジサーバーID
(参考情報)
judge5 / judge4
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
6,816 KB
testcase_01 AC 3 ms
6,944 KB
testcase_02 AC 2 ms
6,944 KB
testcase_03 AC 2 ms
6,940 KB
testcase_04 AC 2 ms
6,940 KB
testcase_05 AC 2 ms
6,940 KB
testcase_06 AC 4 ms
6,944 KB
testcase_07 AC 3 ms
6,940 KB
testcase_08 AC 10 ms
6,944 KB
testcase_09 AC 7 ms
6,940 KB
testcase_10 AC 5 ms
6,940 KB
testcase_11 AC 5 ms
6,944 KB
testcase_12 AC 15 ms
6,944 KB
testcase_13 AC 13 ms
6,944 KB
testcase_14 AC 8 ms
6,944 KB
testcase_15 AC 116 ms
6,944 KB
testcase_16 AC 75 ms
6,940 KB
testcase_17 AC 49 ms
6,940 KB
testcase_18 AC 20 ms
6,944 KB
testcase_19 WA -
testcase_20 AC 123 ms
6,940 KB
testcase_21 AC 261 ms
6,940 KB
testcase_22 AC 117 ms
6,940 KB
testcase_23 AC 3 ms
6,944 KB
testcase_24 AC 72 ms
6,940 KB
testcase_25 AC 116 ms
6,944 KB
testcase_26 AC 171 ms
6,944 KB
testcase_27 AC 46 ms
6,940 KB
testcase_28 AC 45 ms
6,944 KB
testcase_29 WA -
testcase_30 AC 101 ms
6,940 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <bits/stdc++.h>
using namespace std;
typedef signed long long ll;

#undef _P
#define _P(...) (void)printf(__VA_ARGS__)
#define FOR(x,to) for(x=0;x<(to);x++)
#define FORR(x,arr) for(auto& x:arr)
#define ITR(x,c) for(__typeof(c.begin()) x=c.begin();x!=c.end();x++)
#define ALL(a) (a.begin()),(a.end())
#define ZERO(a) memset(a,0,sizeof(a))
#define MINUS(a) memset(a,0xff,sizeof(a))
//-------------------------------------------------------

const int prime_max = 200000;
int NP,prime[100000],divp[prime_max];

void cprime() {
	for(int i=2;i<prime_max;i++) if(divp[i]==0) {
		prime[NP++]=i;
		divp[i]=i;
		for(ll j=1LL*i*i;j>i&&j<prime_max;j+=i) divp[j]=i;
	}
}

int T;
string S;
void solve() {
	int i,j,k,l,r,x,y; string s;
	cprime();
	
	cin>>T;
	while(T--) {
		cin>>S;
		ll ret=0;
		
		multiset<int> M;
		
		for(i=0;i<S.size();i++) {
			
			x = 1;
			FORR(r,M) {
				x=x*r%9;
				if(x==0) break;
			}
			ret += (S[i]-'0')*x;
			
			if(i<S.size()-1) {
				x = S.size()-1-i;
				y = 1+i;
				while(divp[x]) M.insert(divp[x]), x /= divp[x];
				while(divp[y]) M.erase(M.find(divp[y])), y /= divp[y];
			}
		}
		while(ret>=10) ret=ret%10+ret/10;
		
		cout<<ret<<endl;
	}
}


int main(int argc,char** argv){
	string s;int i;
	if(argc==1) ios::sync_with_stdio(false), cin.tie(0);
	FOR(i,argc-1) s+=argv[i+1],s+='\n';
	FOR(i,s.size()) ungetc(s[s.size()-1-i],stdin);
	solve(); return 0;
}
0