結果

問題 No.937 Ultra Sword
ユーザー mfbgjsczmfbgjscz
提出日時 2019-11-25 17:25:37
言語 C++14
(gcc 12.3.0 + boost 1.83.0)
結果
AC  
実行時間 450 ms / 3,000 ms
コード長 2,107 bytes
コンパイル時間 1,728 ms
コンパイル使用メモリ 181,860 KB
実行使用メモリ 11,136 KB
最終ジャッジ日時 2024-05-01 02:25:43
合計ジャッジ時間 10,461 ms
ジャッジサーバーID
(参考情報)
judge5 / judge2
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
5,248 KB
testcase_01 AC 2 ms
5,376 KB
testcase_02 AC 2 ms
5,376 KB
testcase_03 AC 1 ms
5,376 KB
testcase_04 AC 1 ms
5,376 KB
testcase_05 AC 370 ms
5,376 KB
testcase_06 AC 294 ms
9,216 KB
testcase_07 AC 328 ms
9,344 KB
testcase_08 AC 137 ms
7,168 KB
testcase_09 AC 105 ms
6,656 KB
testcase_10 AC 363 ms
9,728 KB
testcase_11 AC 31 ms
5,376 KB
testcase_12 AC 152 ms
5,632 KB
testcase_13 AC 147 ms
5,376 KB
testcase_14 AC 161 ms
5,632 KB
testcase_15 AC 126 ms
5,376 KB
testcase_16 AC 3 ms
5,376 KB
testcase_17 AC 14 ms
5,376 KB
testcase_18 AC 138 ms
5,376 KB
testcase_19 AC 79 ms
5,376 KB
testcase_20 AC 66 ms
5,376 KB
testcase_21 AC 366 ms
11,136 KB
testcase_22 AC 2 ms
5,376 KB
testcase_23 AC 2 ms
5,376 KB
testcase_24 AC 450 ms
5,376 KB
testcase_25 AC 269 ms
5,376 KB
testcase_26 AC 301 ms
5,376 KB
testcase_27 AC 241 ms
5,376 KB
testcase_28 AC 262 ms
5,376 KB
testcase_29 AC 7 ms
5,376 KB
testcase_30 AC 275 ms
5,376 KB
testcase_31 AC 386 ms
5,376 KB
testcase_32 AC 201 ms
5,376 KB
testcase_33 AC 330 ms
5,376 KB
testcase_34 AC 48 ms
5,376 KB
testcase_35 AC 25 ms
5,376 KB
testcase_36 AC 245 ms
5,376 KB
testcase_37 AC 22 ms
5,376 KB
testcase_38 AC 236 ms
5,376 KB
testcase_39 AC 14 ms
5,376 KB
testcase_40 AC 280 ms
5,376 KB
testcase_41 AC 82 ms
5,376 KB
testcase_42 AC 210 ms
5,376 KB
testcase_43 AC 197 ms
5,376 KB
testcase_44 AC 71 ms
5,376 KB
testcase_45 AC 126 ms
5,376 KB
testcase_46 AC 134 ms
5,376 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <bits/stdc++.h>
using namespace std;
#define lli long long int
#define uli unsigned long long int
#define INF 999999999999999999
#define rep(i,m,n) for(lli i = m;i < n;i++)
#define rrep(i,m,n) for(lli i=m-1;i>=n;i--)
#define pb(n) push_back(n)
#define UE(N) N.erase(unique(N.begin(),N.end()),N.end());
#define Sort(n) sort(n.begin(), n.end())
#define Rev(n) reverse(n.begin(),n.end())
#define Out(S) cout << S << endl
#define NeOut(S) cout << S
#define HpOut(S) cout << setprecision(30) << S << endl
#define Vec(K,L,N,S) vector<L> K(N,S)
#define DV(K,L,N,M,S) vector<vector<L>> K(N,vector<L>(M,S))
#define TV(K,L,N,M,R,S) vector<vector<vector<L>>> K(N,vector<vector<L>>(M,vector<L>(R,S)))
#define pint pair<lli,lli>
#define paf(L,R) pair<L,R>
#define mod 1000000007
#define MAX 5100000
#define chmax(a, b) a = (((a)<(b)) ? (b) : (a))
#define chmin(a, b) a = (((a)>(b)) ? (b) : (a))
map<lli,lli> divisor(vector<lli>HP){
  map<lli,lli>res;
  for(auto N:HP){
    for(lli i=1;i*i<=N;i++){
      if(N%i==0){
        res[i]+=N-N/i;
        if(i!=N/i)res[N/i]+=N-N/(N/i);
      }
    }
  }
  return res;
}
lli f2_gcd(bitset<20> A,bitset<20> B) {
	int i;
	for(i=20;i>=0;i--) {
		if(A[i]==1 && B[i]==1) {
			B^=A;
			break;
		}
		if(A[i]==1) break;
		if(B[i]==1) {
			swap(A,B);
			break;
		}
	}
	
	// A>B
	while(1){
		int x;
		for(x=i-1;x>=0;x--)if(B[x]) break;
		if(x<0) break;
		while(i>=x) {
			if(A[i]) A^=B<<(i-x);
			i--;
		}
		i=x;
		swap(A,B);
	}
  lli x=0;
  rep(i,0,20)if(A[i]==1)x+=pow(2,i);
  return x;
}
bool is_multiple(int x,int g){
    int Lx=32-__builtin_clz(x),Lg=32-__builtin_clz(g);
    while(Lx>=Lg&&x!=0){
        x^=g<<(Lx-Lg);
        Lx=32-__builtin_clz(x);
    }
    return x==0;
}
int main(){
  lli A,B,C,D,E,F,N,M,K,L,R,X,Y,H,W,sum=0,num=0,flag=0;string S,T;
  cin >> N;
  Y=0;
  Vec(HP,lli,N,0);
  rep(i,0,N)cin >> HP[i];
  X=f2_gcd(HP[0],HP[1]);
  rep(i,2,N)X=f2_gcd(HP[i],X);
  rep(i,0,N){
    chmax(Y,HP[i]);
    sum+=HP[i];
  }
  num=sum;
  auto St=divisor(HP);
  cerr << St.size() << endl;
  for(auto v:St)if(is_multiple(v.first,X))num=min(num,sum-v.second);
  Out(num);
}
0