結果

問題 No.1343 Dividing Digit
ユーザー kpinkcat
提出日時 2023-09-03 23:44:21
言語 C++17
(gcc 13.3.0 + boost 1.87.0)
結果
AC  
実行時間 27 ms / 2,000 ms
コード長 491 bytes
コンパイル時間 975 ms
コンパイル使用メモリ 101,572 KB
最終ジャッジ日時 2025-02-16 18:29:00
ジャッジサーバーID
(参考情報)
judge5 / judge5
純コード判定しない問題か言語
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 3
other AC * 22
権限があれば一括ダウンロードができます
コンパイルメッセージ
main.cpp: In function ‘int main()’:
main.cpp:23:11: warning: ‘r’ may be used uninitialized [-Wmaybe-uninitialized]
   23 |         r *= k;
      |         ~~^~~~
main.cpp:15:26: note: ‘r’ was declared here
   15 |     long long n, k, cnt, r, mod = 0;
      |                          ^

ソースコード

diff #

#include<stdio.h>
#include<iostream>
#include<map>
#include<vector>
#include <algorithm>
#include<math.h>
#include <iomanip>
#include<set>
#include <numeric>
#include<string>
using namespace std;

int main()
{
    long long n, k, cnt, r, mod = 0;
    cin >> n >> k;
    vector<long long> a(n);
    for (int i = 0; i < n; i++){
        cin >> a[i];
        mod += a[i];
    }
    for (int i = 0; i < n; i++){
        r *= k;
        r += a[i];
        r %= mod;
    }
    cout << r << endl;
}
0