Submission #12400292


Source Code Expand

Copy
#include<bits/stdc++.h>
#define rep(i,a,b) for(int i=a;i<b;i++)
#define rrep(i,a,b) for(int i=a;i>=b;i--)
#define fore(i,a) for(auto &i:a)
#define all(x) (x).begin(),(x).end()
//#pragma GCC optimize ("-O3")
using namespace std; void _main(); int main() { cin.tie(0); ios::sync_with_stdio(false); _main(); }
typedef long long ll; const int inf = INT_MAX / 2; const ll infl = 1LL << 60;
template<class T>bool chmax(T& a, const T& b) { if (a < b) { a = b; return 1; } return 0; }
template<class T>bool chmin(T& a, const T& b) { if (b < a) { a = b; return 1; } return 0; }
//---------------------------------------------------------------------------------------------------
/*---------------------------------------------------------------------------------------------------
            ∧_∧
      ∧_∧  (´<_` )  Welcome to My Coding Space!
     ( ´_ゝ`) /  ⌒i     @hamayanhamayan0
    /   \     | |
    /   / ̄ ̄ ̄ ̄/  |
  __(__ニつ/     _/ .| .|____
     \/____/ (u ⊃
---------------------------------------------------------------------------------------------------*/














string S;
ll cnt[2020];
//---------------------------------------------------------------------------------------------------
void _main() {
	cin >> S;
	int N = S.length();

	ll ans = 0;
	cnt[0] = 1;
	int tot = 0;
	int p = 1;
	rrep(i, N - 1, 0) {
		tot = (tot + (S[i] - '0') * p) % 2019;
		
		ans += cnt[tot];

		p = (p * 10) % 2019;
		cnt[tot]++;
	}
	cout << ans << endl;
}





Submission Info

Submission Time
Task D - Multiple of 2019
User hamayanhamayan
Language C++ (GCC 9.2.1)
Score 400
Code Size 1683 Byte
Status
Exec Time 5 ms
Memory 3740 KB

Judge Result

Set Name Score / Max Score Test Cases
Sample 0 / 0 01.txt, 02.txt, 03.txt
All 400 / 400 01.txt, 02.txt, 03.txt, 11.txt, 12.txt, 13.txt, 14.txt, 15.txt, 16.txt, 17.txt, 18.txt
Case Name Status Exec Time Memory
01.txt 2 ms 3604 KB
02.txt 2 ms 3600 KB
03.txt 2 ms 3528 KB
11.txt 5 ms 3656 KB
12.txt 3 ms 3652 KB
13.txt 2 ms 3520 KB
14.txt 4 ms 3664 KB
15.txt 4 ms 3740 KB
16.txt 2 ms 3640 KB
17.txt 4 ms 3704 KB
18.txt 2 ms 3524 KB