結果

問題 No.1343 Dividing Digit
ユーザー kakao745kakao745
提出日時 2024-09-21 12:31:34
言語 C++23
(gcc 12.3.0 + boost 1.83.0)
結果
WA  
実行時間 -
コード長 2,638 bytes
コンパイル時間 3,287 ms
コンパイル使用メモリ 254,224 KB
実行使用メモリ 6,948 KB
最終ジャッジ日時 2024-09-21 12:31:39
合計ジャッジ時間 4,699 ms
ジャッジサーバーID
(参考情報)
judge1 / 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 -
権限があれば一括ダウンロードができます

ソースコード

diff #

#include<bits/stdc++.h>
using namespace std;
#define itn int
#define rep(i,n) for(long long i=0;i<(long long)n;i++)
#define reps(i,n) for(long long i=1;i<=(long long)n;i++)
#define loop(i,l,r) for(long long i=l;i<=(long long)r;i++)
#define drep(i,n) for(long long i=(long long)n-1;i>=0;i--)
#define all(v) v.begin(), v.end()
#define rall(v) v.rbegin(), v.rend()
#define yn(x) cout << (x? "Yes":"No") << endl;
#define cou(x) cout << x << endl;
#define emp emplace_back
#pragma GCC target ("avx,avx2")//四則演算
#pragma GCC optimize("O3")
#pragma GCC optimize("unroll-loops")//ループ
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")//浮動小数点
const long long mod=998244353LL;
const long long mods=1000000007LL;
const double inf=numeric_limits<double>::infinity();
const int kaz=1000000000;
const long long yab=2500000000000000000LL;
const long long aho =-yab;
const long double eps=1.0e-14L;
const long double pi=acosl(-1.0L);
using ll=long long;
using st=string;
using P=pair<ll,ll>;
using tup=tuple<ll,ll,ll>;
using vi=vector<ll>;
using vin=vector<int>;
using vc=vector<char>;
using vb=vector<bool>;
using vd=vector<double>;
using vs=vector<string>;
using vp=vector<P>;
using sp=set<P>;
using si=set<ll>;
using vvi=vector<vector<ll>>;
using vvin=vector<vin>;
using vvc=vector<vc>;
using vvb=vector<vb>;
using vvvi=vector<vvi>;
using vvvin=vector<vvin>;
const int dx[4]={0,1,0,-1};
const int dy[4]={1,0,-1,0};
const vector<int> ex = {-1, -1, -1, 0, 0, 1, 1, 1};
const vector<int> ey = {-1, 0, 1, -1, 1, -1, 0, 1};
template<typename T>istream&operator>>(istream&is,vector<T>&v){for(T&in:v)is>>in;return is;}
template<typename T>ostream&operator<<(ostream&os,vector<T>v){rep(i,v.size())os<<v[i]<<(i+1!=v.size()?" ":"\n");return os;}
template<typename T1,typename T2>
void co(bool x,T1 y,T2 z){
  if(x)cout << y << endl;
  else cout << z << endl;
}
template<typename T>
bool chmax(T &a, T b){
	if(a<b){
		a=b;
		return true;
	}
	return false;
}
template<typename T>
bool chmin(T &a, T b){
	if(a>b){
		a=b;
		return true;
	}
	return false;
}
template<typename T>
void print(vector<T> &a){
	for(int i=0;i<a.size();i++){
		cout << a[i];
		if(i==(long long)a.size()-1)cout << endl;
		else cout << " ";
	}
}
ll mypow(ll x,ll y,ll m){
	ll ret=1;
	while(y>0){
		if(y&1)ret=ret*x%m;
		x=x*x%m;
		y>>=1;
	}
	return ret;
}
ll nopow(ll x,ll y){
	ll ret=1;
	while(y>0){
		if(y&1)ret*=x;
		x*=x;
		y>>=1;
	}
	return ret;
}
int main(){
	ll n,k;
	cin >> n >> k;
	vi a(n);
	cin >> a;
	reverse(all(a));
	ll t=accumulate(all(a),0LL);
	ll res=0;
	rep(i,n){
		res=(res+a[i]*mypow(k,i-1,t))%t;
	}
	cout << res << endl;
}
0