結果

問題 No.434 占い
ユーザー 👑 kmjpkmjp
提出日時 2016-10-14 23:35:44
言語 C++11
(gcc 11.4.0)
結果
WA  
実行時間 -
コード長 1,603 bytes
コンパイル時間 1,509 ms
コンパイル使用メモリ 163,712 KB
実行使用メモリ 5,376 KB
最終ジャッジ日時 2024-05-01 22:53:53
合計ジャッジ時間 3,703 ms
ジャッジサーバーID
(参考情報)
judge2 / judge4
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
5,248 KB
testcase_01 AC 3 ms
5,376 KB
testcase_02 AC 2 ms
5,376 KB
testcase_03 AC 2 ms
5,376 KB
testcase_04 AC 2 ms
5,376 KB
testcase_05 AC 2 ms
5,376 KB
testcase_06 AC 3 ms
5,376 KB
testcase_07 AC 2 ms
5,376 KB
testcase_08 AC 9 ms
5,376 KB
testcase_09 AC 8 ms
5,376 KB
testcase_10 AC 4 ms
5,376 KB
testcase_11 AC 4 ms
5,376 KB
testcase_12 AC 15 ms
5,376 KB
testcase_13 AC 13 ms
5,376 KB
testcase_14 AC 8 ms
5,376 KB
testcase_15 AC 122 ms
5,376 KB
testcase_16 AC 77 ms
5,376 KB
testcase_17 AC 51 ms
5,376 KB
testcase_18 AC 20 ms
5,376 KB
testcase_19 WA -
testcase_20 AC 134 ms
5,376 KB
testcase_21 AC 272 ms
5,376 KB
testcase_22 AC 117 ms
5,376 KB
testcase_23 AC 2 ms
5,376 KB
testcase_24 AC 74 ms
5,376 KB
testcase_25 AC 117 ms
5,376 KB
testcase_26 AC 171 ms
5,376 KB
testcase_27 AC 49 ms
5,376 KB
testcase_28 AC 45 ms
5,376 KB
testcase_29 WA -
testcase_30 AC 103 ms
5,376 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))
//-------------------------------------------------------

ll modpow(ll a, ll n, ll mo) {
	ll r=1;
	while(n) r=r*((n%2)?a:1)%mo,a=a*a%mo,n>>=1;
	return r;
}

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

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

int T;
string S;
int num[101010];
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];
				}
				if(x>1) M.insert(x);
				while(divp[y]) {
					M.erase(M.find(divp[y]));
					y /= divp[y];
				}
				if(y>1) M.erase(M.find(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