結果
| 問題 |
No.136 Yet Another GCD Problem
|
| コンテスト | |
| ユーザー |
184
|
| 提出日時 | 2015-01-26 00:02:45 |
| 言語 | C++11(廃止可能性あり) (gcc 13.3.0) |
| 結果 |
TLE
(最新)
AC
(最初)
|
| 実行時間 | - |
| コード長 | 659 bytes |
| コンパイル時間 | 252 ms |
| コンパイル使用メモリ | 35,072 KB |
| 実行使用メモリ | 12,288 KB |
| 最終ジャッジ日時 | 2024-06-23 03:03:34 |
| 合計ジャッジ時間 | 12,736 ms |
|
ジャッジサーバーID (参考情報) |
judge2 / judge1 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | TLE * 1 -- * 2 |
| other | -- * 39 |
コンパイルメッセージ
main.cpp: In function ‘int main()’:
main.cpp:12:22: warning: ignoring return value of ‘int scanf(const char*, ...)’ declared with attribute ‘warn_unused_result’ [-Wunused-result]
12 | int n,k;scanf("%d%d",&n,&k);
| ~~~~~^~~~~~~~~~~~~~
ソースコード
#include <cstdio>
#include <cstring>
#include <cstdlib>
#include <algorithm>
using namespace std;
//namaega184
int main(){
int n,k;scanf("%d%d",&n,&k);
int isp[100001]={0,0,1};
for(int i=3;i<=n;i++)if(i&1)isp[i]=1;else isp[i]=0;
for(int i=3;i*i<=n;i+=2){
if(isp[i]){
for(int j=i*i;j<=n;j+=i)isp[j]=0;
}
}
if(n%2==0){
printf("%d\n",n/2);
return 0;
}
else{
int cnt=0;
for(int i=3;i*i<=n;i+=2){
if(!isp[i])continue;
if(n%i==0){
cnt=0;
int nn=n;
while(n!=1){nn/=n;cnt++;}
int ans=i;
cnt/=2;
for(int i=1;i<cnt;i++)ans*=i;
printf("%d\n",ans);
return 0;
}
}
}
printf("%d\n",1);
return 0;
}
184