結果
| 問題 |
No.371 ぼく悪いプライムじゃないよ
|
| コンテスト | |
| ユーザー |
kyuridenamida
|
| 提出日時 | 2016-05-18 22:54:12 |
| 言語 | C++11(廃止可能性あり) (gcc 13.3.0) |
| 結果 |
RE
|
| 実行時間 | - |
| コード長 | 944 bytes |
| コンパイル時間 | 1,462 ms |
| コンパイル使用メモリ | 161,544 KB |
| 実行使用メモリ | 13,640 KB |
| 最終ジャッジ日時 | 2024-10-06 05:43:32 |
| 合計ジャッジ時間 | 4,200 ms |
|
ジャッジサーバーID (参考情報) |
judge2 / judge5 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 4 |
| other | AC * 17 RE * 1 TLE * 1 -- * 23 |
コンパイルメッセージ
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 | }
| ^
ソースコード
#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;
}
}
}
}
kyuridenamida