結果
| 問題 |
No.1233 割り切れない気持ち
|
| コンテスト | |
| ユーザー |
vjudge1
|
| 提出日時 | 2025-08-15 16:04:53 |
| 言語 | C++14 (gcc 13.3.0 + boost 1.87.0) |
| 結果 |
TLE
|
| 実行時間 | - |
| コード長 | 1,263 bytes |
| コンパイル時間 | 1,687 ms |
| コンパイル使用メモリ | 164,208 KB |
| 実行使用メモリ | 19,016 KB |
| 最終ジャッジ日時 | 2025-08-15 16:05:04 |
| 合計ジャッジ時間 | 10,894 ms |
|
ジャッジサーバーID (参考情報) |
judge1 / judge3 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | TLE * 1 -- * 1 |
| other | -- * 39 |
コンパイルメッセージ
main.cpp: In function ‘int main()’:
main.cpp:43:10: warning: ignoring return value of ‘FILE* freopen(const char*, const char*, FILE*)’ declared with attribute ‘warn_unused_result’ [-Wunused-result]
43 | freopen("mod.in", "r", stdin);
| ~~~~~~~^~~~~~~~~~~~~~~~~~~~~~
main.cpp:44:10: warning: ignoring return value of ‘FILE* freopen(const char*, const char*, FILE*)’ declared with attribute ‘warn_unused_result’ [-Wunused-result]
44 | freopen("mod.out", "w", stdout);
| ~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~
ソースコード
#include<bits/stdc++.h>
#pragma GCC optimize("Ofast")
#pragma GCC optimize(3)
using namespace std;
using ll = long long;
char buf[1 << 20], *p1, *p2;
#define gc() \
(p1 == p2 && (p2 = (p1 = buf) + fread(buf, 1, 1 << 20, stdin), p1 == p2) \
? EOF \
: *p1++)
inline int read() {
int s = 0;
for(char ch; ch = gc();) {
if(isdigit(ch)) {
s = s * 10 + ch - '0';
break;
}
}
for(char ch; ch = gc();) {
if(isdigit(ch)) {
s = s * 10 + ch - '0';
}else{
break;
}
}
return s;
}
const int MAXN = 2e5 + 25;
int n;
ll ans;
int a[MAXN];
ll c[MAXN];
int cnt[MAXN];
int main(){
ios::sync_with_stdio(0), cin.tie(0), cout.tie(0);
freopen("mod.in", "r", stdin);
freopen("mod.out", "w", stdout);
n = read();
for(int i = 1; i <= n; i++) {
a[i] = read();
ans += a[i];
cnt[a[i]]++;
}
ans *= n;
for(int i = 1; i <= 2e5; i++) {
if(cnt[i] != 0){
for(int j = i; j <= 2e5; j += i) {
c[j] += 1LL * cnt[i] * i;
}
}
}
partial_sum(c, c + 200001, c);
for(int i = 1; i <= n; i++) {
ans -= c[a[i]];
}
cout << ans;
return 0;
}
vjudge1