skypemifen

5026

NZX

ParticleArts

goldstine

//这里填你的代码^^
//注意代码要放在两组三个点之间，才可以正确显示代码高亮哦~
#include <iostream>
#include <cstring>
#include <algorithm>
using namespace std;

const int N = 2010, MOD = 1e9 + 7;
int c[N][N];

int main() {
int n;
scanf("%d", &n);
for (int i=0; i<N; i++) {
for (int j=0; j<=i; j++) {
if (!j) c[i][j] = 1;
else c[i][j] = (c[i-1][j-1] + c[i-1][j]) % MOD;
}
}
while (n -- ) {
int a, b;
scanf("%d%d", &a, &b);
printf("%d\n", c[a][b]);
}
return 0;
}


//这里填你的代码^^
//注意代码要放在两组三个点之间，才可以正确显示代码高亮哦~
#include <iostream>
#include <cstring>
#include <algorithm>
using namespace std;
typedef long long LL;
const int N = 2010, mod =  998244353;
int c[N][N];
int main() {
int n, m, k;
scanf("%d%d%d", &n, &m, &k);
for (int i=0; i<=n-1; i++) {
for (int j=0; j<=i && j<=k; j++) {
if(!j) c[i][j] = 1;
else c[i][j] = (c[i-1][j] + c[i-1][j-1]) % mod;
}
}
int res = c[n-1][k] % mod;
res = (LL) res * m % mod;
for (int i=0; i<k; i++) {
res = (LL) res * (m-1) % mod;
}
printf("%d\n", res);
return 0;
}


//这里填你的代码^^
//注意代码要放在两组三个点之间，才可以正确显示代码高亮哦~
#include <iostream>
#include <cstring>
#include <algorithm>
using namespace std;
typedef long long LL;
const int N = 100010, mod = 1e9 + 7;
int fact[N], infact[N];

int qmi(int a, int b, int q) {
LL res = 1 % q;
while (b) {
if (b&1) res = res * a % q;
a = (LL)a * a % q;
b >>= 1;
}
return res;
}

int main() {
fact[0] = infact[0] = 1;
for (int i=1; i<N; i++) {
fact[i] = (LL)fact[i-1] * i % mod;
infact[i] = (LL)infact[i-1] * qmi(i, mod - 2, mod) % mod;
}
int n;
scanf("%d", &n);
while (n --) {
int a, b;
scanf("%d%d", &a, &b);
printf("%d\n", (LL)fact[a] * infact[a-b] % mod * infact[b] % mod);
}
return 0;
}


//这里填你的代码^^
//注意代码要放在两组三个点之间，才可以正确显示代码高亮哦~
#include <iostream>
#include <cstring>
#include <algorithm>
using namespace std;

typedef long long LL;

int pmi(int a, int b, int p) {
LL res = 1 % p;
while (b) {
if (b & 1) res = res * a % p;
b >>= 1;
a = (LL) a * a % p;
}
return res;
}

int main() {
int n;
scanf("%d", &n);
while (n--) {
int a, p;
scanf("%d%d", &a, &p);
if (a % p == 0) puts("impossible");
else {
printf("%d\n", pmi(a, p-2, p) );
}
}
return 0;
}


//这里填你的代码^^
//注意代码要放在两组三个点之间，才可以正确显示代码高亮哦~
#include <iostream>
#include <cstring>
#include <algorithm>
using namespace std;

typedef long long LL;

int pmi(int a, int k, int p) {
LL res = 1 % p;
while (k) {
if (k & 1) res = res * a % p;
k >>= 1;
a = (LL)a * a % p;
}
return res;
}

int main() {
int n;
scanf("%d", &n);
while (n --) {
int a, k, p;
scanf("%lld%d%d", &a, &k, &p);
printf("%d\n", pmi(a, k, p));
}
return 0;
}


//这里填你的代码^^
//注意代码要放在两组三个点之间，才可以正确显示代码高亮哦~
#include <iostream>
#include <cstring>
#include <algorithm>
using namespace std;
typedef long long LL;

int pmi(int x, int n, int p) {
LL res = 1 % p;
while (n) {
if (n & 1) res = res * x % p;
n >>= 1;
x = (LL)x * x % p;
}
return res;
}

int main() {
int x,n;
scanf("%d%d", &x, &n);
printf("%d\n", pmi(x,n,233333));
return 0;
}


//这里填你的代码^^
//注意代码要放在两组三个点之间，才可以正确显示代码高亮哦~
#include <iostream>
#include <cstring>
#include <algorithm>
using namespace std;
const int N = 1010;
int a[N][N], s[N][N];
int n,m,q;

void insert(int x1, int y1, int x2, int y2, int c) {
s[x1][y1] += c;
s[x2+1][y1] -= c;
s[x1][y2+1] -= c;
s[x2+1][y2+1] += c;
}

int main() {
scanf("%d%d%d", &n, &m, &q);
for (int i=1; i<=n; i++) {
for (int j=1; j<=m; j++) {
scanf("%d", &a[i][j]);
}
}
for(int i=1; i<=n; i++)
for (int j=1; j<=m; j++)
insert(i, j, i, j, a[i][j]);

while (q--) {
int x1, y1, x2, y2, c;
scanf("%d%d%d%d%d", &x1, &y1, &x2, &y2, &c);
insert(x1, y1, x2, y2, c);
}

for (int i=1; i<=n; i++)
for (int j=1; j<=m; j++)
s[i][j] += s[i-1][j] + s[i][j-1] -s[i-1][j-1];

for (int i=1; i<=n; i++) {
for (int j=1; j<=m; j++)
{
printf("%d ", s[i][j]);
}
puts("");
}
return 0;

}


//这里填你的代码^^
//注意代码要放在两组三个点之间，才可以正确显示代码高亮哦~
#include <iostream>
#include <cstring>
#include <algorithm>
using namespace std;

const int N = 200010;
int b[N];

int main() {
int t;
scanf("%d", &t);
while (t--) {
int n;
scanf("%d", &n);
memset(b, 0, (n+1) * 4);
for (int i=1; i<=n; i++) {
int x;
scanf("%d", &x);
x = min(x, i);
int l = i - x + 1, r = i;
b[l] ++, b[r+1] --;
}
for (int i=1; i<=n; i++) b[i] += b[i-1];
for (int i=1; i<=n; i++) printf("%d ", !!b[i]);
printf("\n");
}
return 0;
}


//这里填你的代码^^
//注意代码要放在两组三个点之间，才可以正确显示代码高亮哦~
#include <iostream>
#include <cstring>
#include <algorithm>
using namespace std;

const int N = 100010;
int n,m;
int a[N], b[N];

void insert(int l, int r, int c) {
b[l] += c;
b[r+1] -= c;
}

int main() {
scanf("%d%d", &n, &m);
for (int i=1; i<=n; i++) scanf("%d", &a[i]);
for (int i=1; i<=n; i++) insert(i, i, a[i]);

while (m --) {
int l, r, c;
scanf("%d%d%d", &l, &r, &c);
insert(l, r, c);
}

for (int i=1; i<=n; i++) b[i] += b[i-1];
for (int i=1; i<=n; i++) printf("%d ", b[i]);
printf("\n");
return 0;
}


//这里填你的代码^^
//注意代码要放在两组三个点之间，才可以正确显示代码高亮哦~
#include <iostream>
#include <cstring>
#include <algorithm>
using namespace std;
typedef long long LL;
const int N = 1e5 + 10;
int n,k;
LL s[N];
int cnt[N];
int main() {
scanf("%d%d", &n, &k);
for (int i=1; i<=n; i++) {
scanf("%d", &s[i]);
s[i] = s[i-1] + s[i];
}
LL res = 0;
cnt[0] ++;
// cnt[s[0] % k] = 1;
//它找的是s0~si-1 中 有 多少个数 s % k 与 si % k 相等；
for (int i=1; i<=n; i++) {
res += cnt[s[i] % k];
cnt[s[i] % k]++;
}
printf("%lld\n", res);
return 0;
}