Contest 2050 and Codeforces Round #718 (Div. 1 + Div. 2)(A-C)

A. Sum of 2050

10^i中i最大的情况。

``````#define int long long
signed main()
{
int n, i, j, t;
cin >> t;
while (t--) {
cin >> n;
int ans = 0;
if (n % 2050 == 0) {
int cnt=0;
while(n!=0){
int d1=0;
for(i=0;;i++){
d1=2050*quickpow(10,i);
if(d1>n) break;
}
n-=2050*quickpow(10,i-1);
cnt++;
}
cout<<cnt<<endl;
}
else {
scf1;
}
}
return 0;
}
``````

B. Morning Jogging

``````
const int maxn = 105;
int ans[maxn][maxn];
int h[maxn];
map<int, int >mo;
struct node {
int v;
int idx;
} a[maxn * maxn];
bool cmp(node a, node b) {
return a.v <  b.v;
}
int main()
{
int n, m, i, j, t;
cin >> t;
while (t--) {
memset(h, 0, sizeof(h));
cin >> n >> m;
int cnt = 0;
for (i = 0; i < n; i++) {
for (j = 0; j < m; j++) {
cin >> a[cnt].v;
a[cnt].idx = i;
cnt++;
}
}
sort(a, a + cnt, cmp);
map<pair<int ,int > , int >mm;
for (i = 0; i < cnt; i++) {
if (i < m) {
ans[a[i].idx][i] = a[i].v;
mm[make_pair(a[i].idx, i)]++;
}
else {
for (j = 0; j < m; j++) {
if (mm[make_pair(a[i].idx, j)] == 0) {
ans[a[i].idx][j] = a[i].v;
mm[make_pair(a[i].idx, j)] = 1;
break;
}
}
}
}
for (i = 0; i < n; i++) {
for (j = 0; j < m; j++) {
cout << ans[i][j] << " ";
}
cout << endl;
}
}
return 0;
}
``````

C. Fillomino 2

``````#include
#include
#define bugg(a,b) cout<
using namespace std;
int mp[505][505];
int a[505];
int n;
void pf() {
int i, j;
for (i = 1; i <= n; i++){
for (j = 1; j <= i-1; j++) {
cout << mp[i][j] << " ";
}
cout << mp[i][j] << endl;
}
}
bool jg(int x, int y) {
if (x > 0 && y <= n && y > 0 && x <= n) {
if (mp[x][y] == 0) {
return true;
}
else
return false;
}
else
return false;
}
void pull (int n,int i){
int x=i, y=i;
int cnt = n-1;
while (cnt--) {
if (jg(x, y-1) == 1) {
mp[x][y-1] = n;
y--;
}
else {
mp[x+1][y] = n;
x++;
}
}
}
int main()
{
int  i, j, d;
cin >> n;
for (i = 1; i <= n; i++) {
cin >> a[i];
mp[i][i] = a[i];
}
for (i = 1; i <= n; i++) {
pull(a[i],i);
}
pf();
}
``````