結果
問題 |
No.1233 割り切れない気持ち
|
ユーザー |
![]() |
提出日時 | 2025-08-15 15:56:40 |
言語 | C++17 (gcc 13.3.0 + boost 1.87.0) |
結果 |
AC
|
実行時間 | 15 ms / 3,153 ms |
コード長 | 1,209 bytes |
コンパイル時間 | 1,954 ms |
コンパイル使用メモリ | 194,232 KB |
実行使用メモリ | 10,484 KB |
最終ジャッジ日時 | 2025-08-15 15:56:44 |
合計ジャッジ時間 | 4,067 ms |
ジャッジサーバーID (参考情報) |
judge5 / judge4 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 2 |
other | AC * 39 |
ソースコード
#include<bits/stdc++.h> using namespace std; #define int long long const int N = 4e5 + 10; int n, a[N], cnt[N], ans, sum; #include <cctype> #include <cstdio> unsigned char buf[1<<20], *p1, *p2; #define gc() (p1==p2 && (p2=(p1=buf)+fread(buf,1,1<<20,stdin)),*p1++) int readint() { int k = 0, f = 1, c = gc(); for (; !isdigit(c); c = gc()) if (c == '-') f = -1; for (; isdigit(c); c = gc()) k = k * 10 + (c ^ 48); return k * f; } void out(int x) { if(x<0)putchar('-'),x=-x; if(x<10)putchar(x+'0'); else out(x/10), putchar(x%10+'0'); } signed main(){ //ios::sync_with_stdio(0), cin.tie(0), cout.tie(0); // freopen("mod.in", "r", stdin); // freopen("mod.out", "w", stdout); n = readint(); for(int i = 1; i <= n; i++){ a[i] = readint(); cnt[a[i]]++; ans += n * a[i]; } for(int i = 1; i <= 4e5; i++){ cnt[i] += cnt[i - 1]; } for(int i = 1; i <= 2e5; i++){ int ttt = cnt[i] - cnt[i - 1]; for(int j = 0; j * i <= 2e5; j++){ int c = 0; if(j * i - 1 >= 0){ c = cnt[(j + 1) * i - 1] - cnt[i * j - 1]; } else{ c = cnt[(j + 1) * i - 1]; } sum += c * ttt * i * j; } } out(ans - sum); return 0; }