結果

問題 No.811 約数の個数の最大化
ユーザー Shuz*Shuz*
提出日時 2018-06-21 12:46:22
言語 C++11
(gcc 11.4.0)
結果
AC  
実行時間 91 ms / 2,000 ms
コード長 848 bytes
コンパイル時間 1,362 ms
コンパイル使用メモリ 144,572 KB
実行使用メモリ 4,380 KB
最終ジャッジ日時 2023-09-22 04:39:21
合計ジャッジ時間 3,353 ms
ジャッジサーバーID
(参考情報)
judge14 / judge15
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 80 ms
4,376 KB
testcase_01 AC 79 ms
4,380 KB
testcase_02 AC 89 ms
4,376 KB
testcase_03 AC 80 ms
4,376 KB
testcase_04 AC 80 ms
4,376 KB
testcase_05 AC 82 ms
4,376 KB
testcase_06 AC 81 ms
4,376 KB
testcase_07 AC 82 ms
4,380 KB
testcase_08 AC 84 ms
4,376 KB
testcase_09 AC 85 ms
4,376 KB
testcase_10 AC 83 ms
4,380 KB
testcase_11 AC 90 ms
4,376 KB
testcase_12 AC 83 ms
4,376 KB
testcase_13 AC 91 ms
4,376 KB
testcase_14 AC 90 ms
4,376 KB
権限があれば一括ダウンロードができます
コンパイルメッセージ
main.cpp: In function ‘int main()’:
main.cpp:29:7: warning: ‘q’ may be used uninitialized in this function [-Wmaybe-uninitialized]
 cout<<q<<endl;}
       ^

ソースコード

diff #

#include<bits/stdc++.h>
using namespace std;

int p[]= {2, 3, 5, 7, 11, 13, 17, 19, 23, 29, 31, 37, 41, 43, 47, 53, 59, 61, 67, 71, 73, 79, 83, 89, 97, 101, 103, 107, 109, 113, 127, 131, 137, 139, 149, 151, 157, 163, 167, 173, 179, 181, 191, 193, 197, 199, 211, 223, 227, 229, 233, 239, 241, 251, 257, 263, 269, 271, 277, 281, 283, 293, 307, 311, 313, 317};
int t=66,i,j;
int s[100000],y[100000]={};

int gcd (int a, int b){
int c;
while(a){c=a;a=b%a;b=c;}
return b;}

void a(){
for(i=0;i-t;++i)s[p[i]]=1;
for(i=4;i-100000;++i)for(j=0;p[j]*p[j]<=i;++j){
if(i%p[j]==0){s[i]=s[i/p[j]]+s[p[j]];break;}
if((p[j]+1)*(p[j]+1)>i)s[i]=1;}}

void b(){
for(i=1;i-100000;++i)for(j=1;j*j<=i;++j){
if(j*j==i)++y[i];else if(i%j==0)y[i]+=2;}}

int main(){
int n,k,m=0,q;
cin>>n>>k;
a();b();
for(i=2;i-n;++i)if(s[gcd(i,n)]>=k&&y[i]>m){
m=y[i];q=i;}
cout<<q<<endl;}
0