結果
問題 | No.990 N×Mマス計算(Kの倍数) |
ユーザー |
![]() |
提出日時 | 2020-02-14 22:35:32 |
言語 | C++17 (gcc 13.3.0 + boost 1.87.0) |
結果 |
WA
|
実行時間 | - |
コード長 | 1,183 bytes |
コンパイル時間 | 2,028 ms |
コンパイル使用メモリ | 202,728 KB |
最終ジャッジ日時 | 2025-01-09 00:22:28 |
ジャッジサーバーID (参考情報) |
judge1 / judge5 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 2 |
other | AC * 10 WA * 9 |
ソースコード
#include <bits/stdc++.h> using namespace std; typedef long long ll; #define inf 10e17 #define rep(i,n) for(long long i=0; i<n; i++) #define repr(i,n,m) for(long long i=m; i<n; i++) #define mod 1000000007 #define sorti(x) sort(x.begin(), x.end()) #define sortd(x) sort(x.begin(), x.end(), std::greater<long long>()) #define debug(x) std::cerr << (x) << std::endl; #define roll(x) for (auto&& itr : x) { cerr << (itr) << " "; } template <class T> inline void chmax(T &ans, T t) { if (t > ans) ans = t;} template <class T> inline void chmin(T &ans, T t) { if (t < ans) ans = t;} inline bool cel(ll t, ll m) { return (t % m) != 0; } int main() { ll n, m, k; cin >> n >> m >> k; string op; cin >> op; vector<ll> b(m), a(n); map<ll, ll> mp; rep(i, m) { cin >> b[i]; b[i] %= k; mp[b[i]] += 1; } rep(i, n) { cin >> a[i]; a[i] %= k; } ll ans = 0; for (auto itr : a) { if (itr == 0) { ans += b.size(); continue; } if (op == "+") { ans += mp[k - itr]; } else { ans += mp[0]; auto sd = k / itr; while (sd < k) { ans += mp[sd]; sd *= 2; } } } cout << ans << endl; }