結果
問題 | No.16 累乗の加算 |
ユーザー | naimonon77 |
提出日時 | 2017-03-12 21:19:23 |
言語 | C++14 (gcc 12.3.0 + boost 1.83.0) |
結果 |
WA
|
実行時間 | - |
コード長 | 4,551 bytes |
コンパイル時間 | 1,804 ms |
コンパイル使用メモリ | 175,468 KB |
実行使用メモリ | 6,944 KB |
最終ジャッジ日時 | 2024-06-30 00:34:45 |
合計ジャッジ時間 | 2,319 ms |
ジャッジサーバーID (参考情報) |
judge1 / judge3 |
(要ログイン)
テストケース
テストケース表示入力 | 結果 | 実行時間 実行使用メモリ |
---|---|---|
testcase_00 | AC | 2 ms
5,248 KB |
testcase_01 | WA | - |
testcase_02 | AC | 2 ms
5,376 KB |
testcase_03 | AC | 2 ms
5,376 KB |
testcase_04 | AC | 2 ms
5,376 KB |
testcase_05 | AC | 2 ms
5,376 KB |
testcase_06 | AC | 2 ms
5,376 KB |
testcase_07 | AC | 2 ms
5,376 KB |
testcase_08 | AC | 2 ms
5,376 KB |
testcase_09 | AC | 2 ms
5,376 KB |
testcase_10 | AC | 2 ms
5,376 KB |
testcase_11 | AC | 2 ms
5,376 KB |
testcase_12 | AC | 2 ms
5,376 KB |
testcase_13 | AC | 2 ms
5,376 KB |
ソースコード
#define _CRT_SECURE_NO_WARNINGS #define _USE_MATH_DEFINES #include "bits/stdc++.h" #include <random> using namespace std; #define rep(i,n) for(int i=0;i<(n);++i) #define rep2(i,a,b) for(int i=(a);i<(b);++i) #define rrep(i,n) for(int i=(n)-1;i>=0;--i) #define rrep2(i,a,b) for(int i=(a)-1;i>=b;--i) #define range(i,a,b,c) for(int i=a;\ c>0?i<b:\ i>b;\ i+=c) #define chmax(a, b) (a = (a) < (b) ? (b) : (a)) #define chmin(a, b) (a = (a) > (b) ? (b) : (a)) using ll = long long; using ull = unsigned long long; using ld = long double; #define all(a) begin(a),end(a) #define ifnot(a) if(not (a)) #define dump(x) cerr << #x << " = " << (x) << endl #define int long long #ifdef _MSC_VER const bool test = true; #else const bool test = false; #endif int dx[] = { 1,0,-1,0 }; int dy[] = { 0,1,0,-1 }; const int INF = 1 << 28; const ll INFL = (ll)1 << 58; //ll mod = (int)1e9 + 7; ll mod = 1000003; const double eps = 1e-10; typedef long double Real; // return -1, 0, 1 int sgn(const Real& r) { return (r > eps) - (r < -eps); } int sgn(const Real& a, const Real &b) { return sgn(a - b); } //..................... const int MAX = (int)2e5 + 5; vector<string> split(const string &str, char sep) { vector<string> v; stringstream ss(str); string buffer; while (getline(ss, buffer, sep)) { v.push_back(buffer); } return v; } template<class InputIterator> int sum(InputIterator begin, InputIterator end) { return accumulate(begin, end, 0ll); } string reverse_res(string s) { reverse(all(s)); return s; } template<typename T> class Matrix { private: vector<vector<T>> data; size_t row_n; size_t column_n; public: Matrix(int a, int b) { data.resize(a); for (int i = 0; i < a; i++) data[i].resize(b); row_n = a; column_n = b; } Matrix(vector<vector<T>> a) { data.resize(a.size()); for (int i = 0; i < a.size(); i++) data[i] = a[0]; row_n = a.size(); column_n = a[0].size(); } const size_t row_size() const { return row_n; } const size_t column_size() const { return column_n; } vector<T>& operator [] (size_t a) { return data[a]; } const vector<T> operator [] (size_t a) const { return data[a]; } template<typename U> Matrix<T> operator %= (const U& b) const { Matrix mat = (*this) % b; (*this) = mat; return *this; } }; template<typename T> bool operator == (const Matrix<T>& a, const Matrix<T>& b) { if (a.row_size() != b.row_size()) return false; if (a.column_size() != b.column_size()) return false; rep(i, a.row_size()) { rep(j, a.column_size()) { if (a[i][j] != b[i][j]) return false; } } return true; } template<typename T> bool operator != (const Matrix<T>& a, const Matrix<T>& b) { return not (a == b); } template<typename T> Matrix<T> operator * (const Matrix<T>& a, const Matrix<T>& b) { if (a.column_size() != b.row_size()) { cerr << "MAT operator *(MAT &,MAT &):Invailed matrix size." << endl; abort(); } int n = a.column_size(); Matrix<T> c(a.row_size(), b.column_size()); rep(i, c.row_size()) { rep(j, c.column_size()) { c[i][j] = 0; rep(k, n) { c[i][j] += a[i][k] * b[k][j]; } } } return c; } template<typename T> vector<T> operator * (const Matrix<T>& a, const vector<T>& x) { if (a.column_size() != x.size()) { cerr << "MAT operator *(MAT &,MAT &):Invailed matrix size." << endl; abort(); } int n = a.column_size(); vector<T> y(a.row_size()); rep(i, y.size()) { y[i] = 0; // cout << "!"; rep(j, n) { y[i] += a[i][j] * x[j]; } } return y; } template<typename T, typename U> Matrix<T> operator % (const Matrix<T>& a, const U& b) { Matrix<T> res = a; rep(i, a.row_size()) rep(j, a.column_size()) { T v = res[i][j] % b; res[i][j] = v; } return res; } /* pow(x,n)はx^nを返すよ! */ template<class T, class U> T mod_pow(T x, U n) { T res = x; n--; while (n > 0) { if (n & 1) res = res * x; x = x * x; x %= mod; n >>= 1; res %= mod; } return res; } int n; //void solve() { // cin >> n; // Matrix<int> A(vector<vector<int>>{ // {100, 1}, // {0, 0} // } // ); //} void solve(void) { ll i, j, k, l; int x, n; ll a; ll ans = 0; cin >> x >> n; rep2(i, 0, n) { cin >> a; ll tmp = 1; ans = (ans + mod_pow(x, a)) % mod;/* */ } cout << ans << endl; } signed main() { srand(time(NULL)); int T = 100; cout << fixed << setprecision(15); rep(i, T) { char s[MAX]; if (scanf("%s", s) == EOF) break; int n = strlen(s); for (int i = n - 1; i > -1; i--) { ungetc(s[i], stdin); } solve(); } return 0; }