結果

問題 No.3296 81-like number
ユーザー rinrion
提出日時 2025-10-05 21:35:36
言語 C++14
(gcc 13.3.0 + boost 1.87.0)
結果
TLE  
実行時間 -
コード長 1,034 bytes
コンパイル時間 3,524 ms
コンパイル使用メモリ 223,288 KB
実行使用メモリ 19,016 KB
最終ジャッジ日時 2025-10-05 21:35:46
合計ジャッジ時間 10,222 ms
ジャッジサーバーID
(参考情報)
judge2 / judge5
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample TLE * 1 -- * 2
other -- * 15
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <bits/stdc++.h>
#include <atcoder/all>
using namespace std;
using namespace atcoder;
using ll = long long;
using vi = vector<int>;
using vvi = vector<vi>;
using vl = vector<ll>;
using vvl = vector<vl>;
using vs = vector<string>;
using vp = vector<pair<int, int>>;

#define rep(i, s, n) for (int i = s; i < (int)(n); i++)
#define sz(x) ((int)(x).size())
constexpr int INFI = 1001001001;
constexpr ll INFL = (1LL << 60);

bool is_prime (int n){
	if(n == 2) return true;
	for (int i = 2; i * i <= n; i++) {
		if (n % i == 0){ 
			return false;
		}
	}

	if (n != 1) return true;
	else return false;
}

int main (){
	ios::sync_with_stdio(false);
	cin.tie(nullptr);

	// input
	ll n;
	cin >> n;
	vl sosu = {};
	for (int i = 2; i * i <= n; ++i){
		// cerr <<"i: "<< i << "\n" ;
		if(!is_prime(i)) continue;
		sosu.push_back(i);
	}

	ll ans = 0;
	for (auto x : sosu){
		ll temp = x;
		while(true){
			temp *= x;
			if(temp <= n){
				ans += temp;
				// cerr <<"temp: "<< temp << "\n" ;
			}
		}
	}
	cout << ans << endl;
	return 0;
}
0