結果

問題 No.371 ぼく悪いプライムじゃないよ
ユーザー kyuridenamidakyuridenamida
提出日時 2016-05-18 22:54:12
言語 C++11
(gcc 11.4.0)
結果
RE  
実行時間 -
コード長 944 bytes
コンパイル時間 1,309 ms
コンパイル使用メモリ 159,712 KB
実行使用メモリ 8,576 KB
最終ジャッジ日時 2024-04-15 22:59:39
合計ジャッジ時間 4,211 ms
ジャッジサーバーID
(参考情報)
judge5 / judge4
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
5,248 KB
testcase_01 AC 1 ms
5,376 KB
testcase_02 AC 2 ms
5,376 KB
testcase_03 AC 2 ms
5,376 KB
testcase_04 AC 1 ms
5,376 KB
testcase_05 AC 1 ms
5,376 KB
testcase_06 AC 1 ms
5,376 KB
testcase_07 AC 2 ms
5,376 KB
testcase_08 AC 2 ms
5,376 KB
testcase_09 AC 1 ms
5,376 KB
testcase_10 AC 2 ms
5,376 KB
testcase_11 AC 2 ms
5,376 KB
testcase_12 AC 1 ms
5,376 KB
testcase_13 AC 2 ms
5,376 KB
testcase_14 AC 1 ms
5,376 KB
testcase_15 AC 2 ms
5,376 KB
testcase_16 AC 1 ms
5,376 KB
testcase_17 AC 1 ms
5,376 KB
testcase_18 AC 2 ms
5,376 KB
testcase_19 AC 2 ms
5,376 KB
testcase_20 RE -
testcase_21 AC 2 ms
5,376 KB
testcase_22 TLE -
testcase_23 -- -
testcase_24 -- -
testcase_25 -- -
testcase_26 -- -
testcase_27 -- -
testcase_28 -- -
testcase_29 -- -
testcase_30 -- -
testcase_31 -- -
testcase_32 -- -
testcase_33 -- -
testcase_34 -- -
testcase_35 -- -
testcase_36 -- -
testcase_37 -- -
testcase_38 -- -
testcase_39 -- -
testcase_40 -- -
testcase_41 -- -
testcase_42 -- -
testcase_43 -- -
testcase_44 -- -
testcase_45 -- -
権限があれば一括ダウンロードができます
コンパイルメッセージ
main.cpp: In function ‘int main2(long long int, long long int)’:
main.cpp:41:1: warning: no return statement in function returning non-void [-Wreturn-type]
   41 | }
      | ^

ソースコード

diff #

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


long long g(int n){
	long long mx = 1e18;
	for(long long i = 2 ; i*i <= n ; i++){
		if( n % i == 0 ) return i;
	}
	return n;
}
long long f(int n){
	long long mx = 1e18;
	for(long long i = 2 ; i*i <= n ; i++){
		if( n % i == 0 ) return i;
	}
	return 0;
}


int main2(long long L,long long H){
	long long val = 0;
	long long ans = 0;
	while(H >= L){
		long long tm = f(H);
		cout << H << endl;
		if( tm*tm == H ){
			if( ans < tm ){
				ans = tm;
				val = H;
			}
			break;
		}
		if( ans < tm ){
			ans = tm;
			val = H;
		}
		H--;
	}
	cout << val << endl;
}


int main(){
	long long L,H;
	cin >> L >> H;
	if( H - L >= 100000 ){
		main2(L,H);
		return 0;
	}
	for(long long i = sqrt(H)+0.5 ; i >= 1 ; i--){
		if( f(i) == 0 ){
			long long x = (H/i);


			while( x >= i and g(x) < i ) x--;
			if( x != 1 and g(x) >= i and x*i >= L and x*i <= H) {
				cout << x*i << endl;
				return 0;
			}
		}
	}
}
0