結果

問題 No.1233 割り切れない気持ち
ユーザー vjudge1
提出日時 2025-08-15 16:33:21
言語 C++17
(gcc 13.3.0 + boost 1.87.0)
結果
WA  
実行時間 -
コード長 4,262 bytes
コンパイル時間 2,338 ms
コンパイル使用メモリ 196,720 KB
実行使用メモリ 9,344 KB
最終ジャッジ日時 2025-08-15 16:33:27
合計ジャッジ時間 4,584 ms
ジャッジサーバーID
(参考情報)
judge2 / judge1
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 2
other AC * 9 WA * 30
権限があれば一括ダウンロードができます
コンパイルメッセージ
main.cpp:23:39: warning: bad option ‘-fwhole-program’ to pragma ‘optimize’ [-Wpragmas]
   23 | #pragma GCC optimize("-fwhole-program")
      |                                       ^
main.cpp:30:41: warning: bad option ‘-fstrict-overflow’ to pragma ‘optimize’ [-Wpragmas]
   30 | #pragma GCC optimize("-fstrict-overflow")
      |                                         ^
main.cpp:32:41: warning: bad option ‘-fcse-skip-blocks’ to pragma ‘optimize’ [-Wpragmas]
   32 | #pragma GCC optimize("-fcse-skip-blocks")
      |                                         ^
main.cpp:46:51: warning: bad option ‘-funsafe-loop-optimizations’ to pragma ‘optimize’ [-Wpragmas]
   46 | #pragma GCC optimize("-funsafe-loop-optimizations")
      |                                                   ^
main.cpp:49:32: warning: bad option ‘-funroll 8’ to pragma ‘optimize’ [-Wpragmas]
   49 | #pragma GCC optimize("unroll 8")
      |                                ^
main.cpp:61:13: warning: bad option ‘-fwhole-program’ to attribute ‘optimize’ [-Wattributes]
   61 | int readint() {
      |             ^
main.cpp:61:13: warning: bad option ‘-fstrict-overflow’ to attribute ‘optimize’ [-Wattributes]
main.cpp:61:13: warning: bad option ‘-fcse-skip-blocks’ to attribute ‘optimize’ [-Wattributes]
main.cpp:61:13: warning: bad option ‘-funsafe-loop-optimizations’ to attribute ‘optimize’ [-Wattributes]
main.cpp:61:13: warning: bad option ‘-funroll 8’ to attribute ‘optimize’ [-Wattributes]
main.cpp:77:24: warning: bad option ‘-fwhole-program’ to attribute ‘optimize’ [-Wattributes]
   77 | inline void write(int x) {
      |                        ^
main.cpp:77:24: warning: bad option ‘-fstrict-overflow’ to attribute ‘optimize’ [-Wattributes]
main.cpp:77:24: warning: bad option ‘-fcse-skip-blocks’ to attribute ‘optimize’ [-Wattributes]
main.cpp:77:24: warning: bad option ‘-funsafe-loop-optimizations’ to attrib

ソースコード

diff #

#include<bits/stdc++.h>
#pragma GCC optimize(8)
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,avx2,fma")
#pragma GCC optimize("Ofast")
#pragma GCC optimize("inline")
#pragma GCC optimize("-fgcse")
#pragma GCC optimize("-fgcse-lm")
#pragma GCC optimize("-fipa-sra")
#pragma GCC optimize("-ftree-pre")
#pragma GCC optimize("-ftree-vrp")
#pragma GCC optimize("-fpeephole")
#pragma GCC optimize("-ffast-math")
#pragma GCC optimize("-fsched-spec")
#pragma GCC optimize("unroll-loops")
#pragma GCC optimize("-falign-jumps")
#pragma GCC optimize("-falign-loops")
#pragma GCC optimize("-falign-labels")
#pragma GCC optimize("-fdevirtualize")
#pragma GCC optimize("-fcaller-saves")
#pragma GCC optimize("-fcrossjumping")
#pragma GCC optimize("-fthread-jumps")
#pragma GCC optimize("-funroll-loops")
#pragma GCC optimize("-fwhole-program")
#pragma GCC optimize("-freorder-blocks")
#pragma GCC optimize("-fschedule-insns")
#pragma GCC optimize("inline-functions")
#pragma GCC optimize("-ftree-tail-merge")
#pragma GCC optimize("-fschedule-insns2")
#pragma GCC optimize("-fstrict-aliasing")
#pragma GCC optimize("-fstrict-overflow")
#pragma GCC optimize("-falign-functions")
#pragma GCC optimize("-fcse-skip-blocks")
#pragma GCC optimize("-fcse-follow-jumps")
#pragma GCC optimize("-fsched-interblock")
#pragma GCC optimize("-fpartial-inlining")
#pragma GCC optimize("no-stack-protector")
#pragma GCC optimize("-freorder-functions")
#pragma GCC optimize("-findirect-inlining")
#pragma GCC optimize("-fhoist-adjacent-loads")
#pragma GCC optimize("-frerun-cse-after-loop")
#pragma GCC optimize("inline-small-functions")
#pragma GCC optimize("-finline-small-functions")
#pragma GCC optimize("-ftree-switch-conversion")
#pragma GCC optimize("-foptimize-sibling-calls")
#pragma GCC optimize("-fexpensive-optimizations")
#pragma GCC optimize("-funsafe-loop-optimizations")
#pragma GCC optimize("inline-functions-called-once")
#pragma GCC optimize("-fdelete-null-pointer-checks")
#pragma GCC optimize("unroll 8")
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;
}

#include <stdio.h>
#include <string.h>
#define BUF (1 << 22)
#define putchar(x) (now ++[0] = (x)) // ??? putchar
typedef int i32;
unsigned char obuf[BUF + 17], // ?????????????????????
  *now = obuf;

unsigned char fr[17];
inline void write(int x) {
	if (!x) return(void)(putchar(48));
	if (x == -2147483648) return(void)(memmove(now, "-2147483648", 11), now += 11);
	unsigned char* tot = fr + 17;
	(x < 0) && (now ++[0] = 45, x = -x);
	(x) && ((-- tot)[0] = x % 10 | 48, x /= 10),
	(x) && ((-- tot)[0] = x % 10 | 48, x /= 10),
	(x) && ((-- tot)[0] = x % 10 | 48, x /= 10),
	(x) && ((-- tot)[0] = x % 10 | 48, x /= 10),
	(x) && ((-- tot)[0] = x % 10 | 48, x /= 10),
	(x) && ((-- tot)[0] = x % 10 | 48, x /= 10),
	(x) && ((-- tot)[0] = x % 10 | 48, x /= 10),
	(x) && ((-- tot)[0] = x % 10 | 48, x /= 10),
	(x) && ((-- tot)[0] = x % 10 | 48, x /= 10),
	(x) && ((-- tot)[0] = x % 10 | 48, x /= 10);
	memmove(now, tot, fr + 17 - tot); // ????
	now += fr + 17 - tot;
}

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;
    }
  }
  int x = ans - sum;
 for (int i = 1; i <= 1; ++ i) {
		write(x), putchar(10);
		if (now - obuf > BUF) { // ?????????????
			fwrite(obuf, 1, now - obuf, stdout);
			now = obuf;
		}
	}
	fwrite(obuf, 1, now - obuf, stdout); // ??????????
  return 0;
}
0