結果

問題 No.1409 Simple Math in yukicoder
ユーザー publflpublfl
提出日時 2021-02-26 22:58:37
言語 C++14
(gcc 12.3.0 + boost 1.83.0)
結果
TLE  
実行時間 -
コード長 1,008 bytes
コンパイル時間 454 ms
コンパイル使用メモリ 50,304 KB
実行使用メモリ 11,296 KB
最終ジャッジ日時 2024-04-10 13:40:26
合計ジャッジ時間 25,797 ms
ジャッジサーバーID
(参考情報)
judge1 / judge3
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
6,816 KB
testcase_01 AC 1 ms
6,944 KB
testcase_02 AC 1 ms
6,940 KB
testcase_03 AC 1 ms
6,944 KB
testcase_04 AC 1 ms
6,944 KB
testcase_05 AC 1 ms
6,940 KB
testcase_06 AC 1 ms
6,940 KB
testcase_07 AC 129 ms
6,940 KB
testcase_08 AC 510 ms
6,940 KB
testcase_09 AC 150 ms
6,940 KB
testcase_10 AC 385 ms
6,940 KB
testcase_11 AC 550 ms
6,940 KB
testcase_12 AC 394 ms
6,940 KB
testcase_13 AC 141 ms
6,940 KB
testcase_14 AC 123 ms
6,944 KB
testcase_15 AC 179 ms
6,944 KB
testcase_16 AC 223 ms
6,944 KB
testcase_17 AC 753 ms
6,940 KB
testcase_18 AC 316 ms
6,944 KB
testcase_19 AC 364 ms
6,940 KB
testcase_20 AC 296 ms
6,940 KB
testcase_21 AC 240 ms
6,944 KB
testcase_22 AC 474 ms
6,940 KB
testcase_23 AC 98 ms
6,944 KB
testcase_24 AC 70 ms
6,940 KB
testcase_25 AC 472 ms
6,940 KB
testcase_26 AC 480 ms
6,940 KB
testcase_27 AC 829 ms
6,944 KB
testcase_28 AC 773 ms
6,944 KB
testcase_29 AC 825 ms
6,940 KB
testcase_30 AC 824 ms
6,940 KB
testcase_31 AC 784 ms
6,940 KB
testcase_32 AC 789 ms
6,944 KB
testcase_33 AC 741 ms
6,940 KB
testcase_34 AC 776 ms
6,944 KB
testcase_35 AC 816 ms
6,940 KB
testcase_36 AC 788 ms
6,940 KB
testcase_37 TLE -
testcase_38 -- -
testcase_39 -- -
testcase_40 -- -
testcase_41 -- -
testcase_42 -- -
testcase_43 -- -
testcase_44 -- -
testcase_45 -- -
testcase_46 -- -
testcase_47 -- -
testcase_48 -- -
testcase_49 -- -
testcase_50 -- -
testcase_51 -- -
testcase_52 -- -
testcase_53 -- -
testcase_54 -- -
testcase_55 -- -
testcase_56 -- -
testcase_57 -- -
testcase_58 -- -
testcase_59 -- -
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <stdio.h>
#include <vector>

long long int power(long long int a, long long int b, int p)
{
	long long int ans = 1;
	long long int k = a;
	while(b)
	{
		if(b%2==1) ans*=k, ans%=p;
		k*=k, k%=p;
		b/=2;
	}
	return ans;
}
long long int inv(long long int a, int p)
{
	return power(a,p-2,p);
}

long long int fact[110];
std::vector<int> ans;
long long int check[100010];

int main()
{
	fact[0] = 1;
	int T;
	scanf("%d",&T);
	while(T--)
	{
		ans.clear();
		int a,b;
		scanf("%d%d",&a,&b);
		int p = a*b+1;
		
		int count = 0;
		for(int i=1;i<=a*b;i++) check[i] = 0;
		for(int i=1;i<=a*b;i++)
		{
			if(check[i]==0)
			{
				long long int t = power(i,b,p);
				long long int i2 = i;
				long long int s = t;
				
				while(check[i2]==0)
				{
					check[i2] = s;
					if(s==1) count++;
					if(count>=b) goto u;
					i2 = (i2*i)%p;
					s = (s*t)%p;
				}
			}
		}
		u:;
		for(int i=1;i<=a*b;i++) if(check[i]==1) ans.push_back(i);
		for(int i=0;i<ans.size();i++) printf("%d ",ans[i]);
		printf("\n");
	}
}
0