結果

問題 No.312 置換処理
ユーザー naimonon77naimonon77
提出日時 2015-12-11 19:14:27
言語 C++11
(gcc 11.4.0)
結果
WA  
実行時間 -
コード長 1,156 bytes
コンパイル時間 620 ms
コンパイル使用メモリ 64,008 KB
実行使用メモリ 9,744 KB
最終ジャッジ日時 2023-10-13 11:16:37
合計ジャッジ時間 2,551 ms
ジャッジサーバーID
(参考情報)
judge14 / judge11
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 10 ms
9,556 KB
testcase_01 AC 11 ms
9,544 KB
testcase_02 AC 12 ms
9,704 KB
testcase_03 AC 11 ms
9,692 KB
testcase_04 AC 11 ms
9,548 KB
testcase_05 AC 11 ms
9,612 KB
testcase_06 AC 11 ms
9,648 KB
testcase_07 AC 11 ms
9,508 KB
testcase_08 AC 11 ms
9,688 KB
testcase_09 AC 10 ms
9,648 KB
testcase_10 AC 11 ms
9,636 KB
testcase_11 AC 10 ms
9,640 KB
testcase_12 AC 10 ms
9,692 KB
testcase_13 WA -
testcase_14 WA -
testcase_15 WA -
testcase_16 WA -
testcase_17 WA -
testcase_18 WA -
testcase_19 WA -
testcase_20 WA -
testcase_21 WA -
testcase_22 AC 10 ms
9,716 KB
testcase_23 WA -
testcase_24 AC 12 ms
9,544 KB
testcase_25 AC 10 ms
9,736 KB
testcase_26 AC 10 ms
9,700 KB
testcase_27 AC 12 ms
9,612 KB
testcase_28 AC 11 ms
9,612 KB
testcase_29 AC 11 ms
9,540 KB
testcase_30 AC 12 ms
9,624 KB
testcase_31 WA -
testcase_32 AC 11 ms
9,624 KB
testcase_33 AC 12 ms
9,692 KB
testcase_34 AC 11 ms
9,700 KB
testcase_35 AC 11 ms
9,556 KB
testcase_36 AC 11 ms
9,540 KB
testcase_37 AC 11 ms
9,644 KB
testcase_38 WA -
testcase_39 AC 11 ms
9,528 KB
testcase_40 AC 10 ms
9,516 KB
testcase_41 AC 11 ms
9,516 KB
testcase_42 AC 11 ms
9,560 KB
testcase_43 AC 11 ms
9,544 KB
testcase_44 WA -
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <iostream>
#include <cstring>
#include <algorithm>
#include <limits.h>
#include <cstdio>
#include <cmath>
#define REP(i,a,b) for(i=a;i<b;i++)
#define rep(i,n) REP(i,0,n)

using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef long double ld;
/* ここからが本編 */
/*  */

/* eratosthenes(int prime[],int n)は
nまでの素数をprimeに、2,3,と入れていきます */
/* 実行後arr[i]はiが素数の時1になります */
int a = 0;
void eratosthenes(int prime[],int n){
   static int arr[1000009];
   for(int i = 0; i < n; i++){
      arr[i] = 1;
   }
   for(int i = 2; i < sqrt((double)n); i++){
      if(arr[i]){
         for(int j = 0; i * (j + 2) < n; j++){
            arr[i *(j + 2)] = 0;
         }
      }
   }
   for(int i = 2; i < n; i++){
      if(arr[i]){
         prime[a++] = i;
      }
   }
}
int main(void)
{
  int i,j,k;
  static int prime[1000005];
  ull n;
  eratosthenes(prime,1000003);
  cin >> n;
  for(i=1;i<a;i++) {
	if(n % prime[i] == 0) {
	  printf("%d\n",prime[i]); break;
	}
  }
  if(i == a) {
	if(n % 2 == 0) printf("%llu\n",n/2);
	else printf("%llu\n",n);
  }
  return 0;
}
0