結果

問題 No.937 Ultra Sword
ユーザー mfbgjsczmfbgjscz
提出日時 2019-11-24 03:20:55
言語 C++14
(gcc 12.3.0 + boost 1.83.0)
結果
WA  
実行時間 -
コード長 1,664 bytes
コンパイル時間 1,908 ms
コンパイル使用メモリ 173,420 KB
実行使用メモリ 5,376 KB
最終ジャッジ日時 2024-05-01 02:20:40
合計ジャッジ時間 4,742 ms
ジャッジサーバーID
(参考情報)
judge2 / judge4
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 WA -
testcase_01 WA -
testcase_02 WA -
testcase_03 WA -
testcase_04 WA -
testcase_05 WA -
testcase_06 WA -
testcase_07 WA -
testcase_08 WA -
testcase_09 WA -
testcase_10 WA -
testcase_11 WA -
testcase_12 WA -
testcase_13 WA -
testcase_14 WA -
testcase_15 WA -
testcase_16 WA -
testcase_17 WA -
testcase_18 WA -
testcase_19 WA -
testcase_20 WA -
testcase_21 WA -
testcase_22 WA -
testcase_23 WA -
testcase_24 WA -
testcase_25 WA -
testcase_26 WA -
testcase_27 WA -
testcase_28 WA -
testcase_29 WA -
testcase_30 WA -
testcase_31 WA -
testcase_32 WA -
testcase_33 WA -
testcase_34 WA -
testcase_35 WA -
testcase_36 WA -
testcase_37 WA -
testcase_38 WA -
testcase_39 WA -
testcase_40 WA -
testcase_41 WA -
testcase_42 WA -
testcase_43 WA -
testcase_44 WA -
testcase_45 WA -
testcase_46 WA -
権限があれば一括ダウンロードができます

ソースコード

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 ALL(a)  a.begin(),a.end()
#define chmax(a, b) a = (((a)<(b)) ? (b) : (a))
#define chmin(a, b) a = (((a)>(b)) ? (b) : (a))
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;
}
int main(){
  lli A,B,C,D,E,F,N,M,K,L,R,X,Y,Z,H,W,sum=0,num=0,flag=0;string S,T;
  cin >> N;
  Vec(P,lli,N,0);
  rep(i,0,N)cin >> P[i];
  Sort(P);
  Y=P[N-1];
  rep(i,0,N){
    if(P[i]!=Y)sum+=P[i];
    else sum++;
  }
  X=f2_gcd(P[0],P[1]);
  rep(i,2,N)X=f2_gcd(X,P[i]);
  Out(X);
  rep(i,0,N)num+=P[i]/X;
  Out(min(sum,num));
}
0