結果

問題 No.1343 Dividing Digit
ユーザー sushitorunasushitoruna
提出日時 2021-01-16 13:18:34
言語 C++14
(gcc 13.2.0 + boost 1.83.0)
結果
AC  
実行時間 58 ms / 2,000 ms
コード長 1,643 bytes
コンパイル時間 2,819 ms
コンパイル使用メモリ 167,092 KB
実行使用メモリ 4,380 KB
最終ジャッジ日時 2023-08-18 09:43:12
合計ジャッジ時間 3,615 ms
ジャッジサーバーID
(参考情報)
judge12 / judge13
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
4,376 KB
testcase_01 AC 1 ms
4,376 KB
testcase_02 AC 1 ms
4,380 KB
testcase_03 AC 55 ms
4,376 KB
testcase_04 AC 6 ms
4,376 KB
testcase_05 AC 16 ms
4,376 KB
testcase_06 AC 10 ms
4,376 KB
testcase_07 AC 21 ms
4,380 KB
testcase_08 AC 44 ms
4,376 KB
testcase_09 AC 49 ms
4,380 KB
testcase_10 AC 9 ms
4,376 KB
testcase_11 AC 19 ms
4,376 KB
testcase_12 AC 40 ms
4,376 KB
testcase_13 AC 37 ms
4,380 KB
testcase_14 AC 8 ms
4,376 KB
testcase_15 AC 18 ms
4,376 KB
testcase_16 AC 8 ms
4,376 KB
testcase_17 AC 49 ms
4,376 KB
testcase_18 AC 54 ms
4,376 KB
testcase_19 AC 36 ms
4,376 KB
testcase_20 AC 25 ms
4,380 KB
testcase_21 AC 46 ms
4,376 KB
testcase_22 AC 46 ms
4,376 KB
testcase_23 AC 58 ms
4,376 KB
testcase_24 AC 49 ms
4,376 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <bits/stdc++.h>
using namespace std;
using vi = vector <int>;using vl = vector <long long>;
using vs = vector <string>;using vc = vector <char>;
using ll= long long;using vvl = vector<vector<ll> >;
using vvc = vector<vector<char> >;using vd = vector <double>;
using vpl = vector <pair<ll,ll> >;using vb = vector<bool>;
#define rep(i,r) for(ll i=0;i<(r);i++)
#define Rep(i,l,r) for(ll i=(l);i<(r);i++)
#define print(n) cout<<n<<endl
#define vin(a) rep(i,a.size())cin>>a[i]
#define sortp(d) sort(d.begin(),d.end()) //1234
#define sortm(d) sort(d.rbegin(),d.rend()) //4321
#define all(n) n.begin(),n.end()
 //各位の和 
int wa(ll x){ll sum=0;while(x!=0){sum+=x%10;x/=10;}return sum;}
/*-----------順列生成-----------------
do {
} while (next_permutation(配列変数.begin(), 配列変数.end()));*/
//最大公約数 ユークリッドの互除法
ll gcd(ll a, ll b) {if (b==0) return a;else return gcd(b, a%b);}
//最小公倍数 a*b/gcd
ll lcm(ll a,ll b){return a/gcd(a,b)*b;}
//'A'65,'a'97
/*小数点精度指定
cout<<fixed<<setprecision(9)<<;
*/
//priority_queue 優先度付きキュー
ll modpow(ll a,ll n,ll mod) {ll res=1;while(n>0)
{if(n&1)res=res*a%mod;a=a*a%mod;n >>= 1;}return res;}
ll modinv(ll a,ll mod){return modpow(a, mod - 2, mod);}

ll p=0,q=0,r=0;
int dx[8]={1,0,-1,0,1,-1,-1,1};int dy[8]={0,1,0,-1,1,1,-1,-1};
#define inf 1000000000000 //10^12:∞
#define mod 1000000007 //10^9+7:合同式の法
const long double pi = acos(-1);

int main()
{
  ll n,k;cin>>n>>k;
  vl a(n);
  rep(i,n)
  {
    cin>>a[i];
    q+=a[i];
  }
  rep(i,n)
  {
    p+=(modpow(k,(n-i-1),q)*a[i])%q;
    p%=q;
  }
  print(p);
}
0