結果

問題 No.434 占い
ユーザー kotatsugamekotatsugame
提出日時 2020-02-17 06:01:34
言語 C++14
(gcc 12.3.0 + boost 1.83.0)
結果
AC  
実行時間 195 ms / 2,000 ms
コード長 702 bytes
コンパイル時間 640 ms
コンパイル使用メモリ 67,064 KB
実行使用メモリ 8,448 KB
最終ジャッジ日時 2024-04-16 03:43:32
合計ジャッジ時間 4,201 ms
ジャッジサーバーID
(参考情報)
judge3 / judge1
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 50 ms
8,064 KB
testcase_01 AC 51 ms
8,192 KB
testcase_02 AC 50 ms
8,064 KB
testcase_03 AC 50 ms
8,064 KB
testcase_04 AC 50 ms
8,192 KB
testcase_05 AC 50 ms
8,064 KB
testcase_06 AC 51 ms
8,192 KB
testcase_07 AC 50 ms
8,192 KB
testcase_08 AC 53 ms
8,192 KB
testcase_09 AC 52 ms
8,064 KB
testcase_10 AC 51 ms
8,192 KB
testcase_11 AC 52 ms
8,064 KB
testcase_12 AC 65 ms
8,192 KB
testcase_13 AC 53 ms
8,064 KB
testcase_14 AC 52 ms
8,320 KB
testcase_15 AC 90 ms
8,320 KB
testcase_16 AC 78 ms
8,064 KB
testcase_17 AC 67 ms
8,064 KB
testcase_18 AC 59 ms
8,192 KB
testcase_19 AC 69 ms
8,192 KB
testcase_20 AC 195 ms
8,192 KB
testcase_21 AC 90 ms
8,320 KB
testcase_22 AC 78 ms
8,192 KB
testcase_23 AC 50 ms
8,192 KB
testcase_24 AC 78 ms
8,192 KB
testcase_25 AC 90 ms
8,448 KB
testcase_26 AC 66 ms
8,320 KB
testcase_27 AC 65 ms
8,064 KB
testcase_28 AC 65 ms
8,192 KB
testcase_29 AC 75 ms
8,064 KB
testcase_30 AC 163 ms
8,320 KB
権限があれば一括ダウンロードができます
コンパイルメッセージ
main.cpp:14:1: warning: ISO C++ forbids declaration of 'main' with no type [-Wreturn-type]
   14 | main()
      | ^~~~

ソースコード

diff #

#include<iostream>
using namespace std;
int F[1<<17][9];
int power(int a,int b){return b?power(a*a%9,b/2)*(b%2?a:1)%9:1;}
int c(int a,int b)
{
	int ret=1;
	for(int j=0;j<9;j++)
	{
		ret=ret*power(j,F[a][j]-F[a-b][j]-F[b][j])%9;
	}
	return ret;
}
main()
{
	for(int i=1;i<1<<17;i++)
	{
		for(int j=0;j<9;j++)F[i][j]=F[i-1][j];
		int t=i;
		for(int j=2;j*j<=t;j++)
		{
			while(t%j==0)
			{
				F[i][j%9]++;
				t/=j;
			}
		}
		if(t>1)F[i][t%9]++;
	}
	int N;
	cin>>N;
	for(;N--;)
	{
		string s;cin>>s;
		int ret=0;
		bool flag=false;
		for(int i=0;i<s.size();i++)
		{
			if(s[i]!='0')flag=true;
			ret=(ret+(s[i]-'0')*c(s.size()-1,i))%9;
		}
		if(flag)cout<<(ret?ret:9)<<endl;
		else cout<<0<<endl;
	}
}
0