abc 343 B
// 是一道会在输出格式卡人的题,注意结尾不能有空格
int main()
{
scanf("%d", &n);
for (int i = 1; i <= n; i ++)
{
bool st = false;
for (int j = 1; j <= n; j ++)
{
scanf("%d", &a);
if (a)
{
if (st) printf(" ");
st = true;
printf("%d", j);
}
}
printf("\n");
}
return 0;
}
abc 341 B
// 题目不好读;会爆 int;
#include <iostream>
using namespace std;
const int N = 200010;
int n;
long long a[N];
int main()
{
scanf("%d", &n);
for (int i = 0; i < n; i ++) scanf("%lld", &a[i]);
for (int i = 0; i < n - 1; i ++)
{
long long s, t;
scanf("%lld%lld", &s, &t);
a[i + 1] += a[i] / s * t;
}
printf("%lld\n", a[n - 1]);
return 0;
}
abc 339 B
#include <iostream>
using namespace std;
const int N = 110;
int g[N][N], h, w, n;
int dx[4] = {-1, 0, 1, 0}, dy[4] = {0, 1, 0, -1};
int d = 0;
void turn(int col)
{
if (col) d += 3;
else d ++ ;
d %= 4;
}
void get_location(int &x, int &y)
{
x += dx[d], y += dy[d];
x = (x + h) % h;
y = (y + w) % w;
}
int main()
{
cin >> h >> w >> n;
int x = 0, y = 0;
while (n --)
{
turn(g[x][y]);
g[x][y] ^= 1;
get_location(x, y);
}
for (int i = 0; i < h; i ++)
{
for (int j = 0; j < w; j ++)
if (g[i][j]) cout << '#';
else cout << '.';
puts("");
}
return 0;
}
abc 334 B
// 向上取整和向下取整
#include <iostream>
using namespace std;
long long a, m, l, r;
int main()
{
cin >> a >> m >> l >> r;
long long i, j;
if (l - a >= 0) i = (l - a + m - 1) / m;
else i = (l - a) / m;
if (r - a >= 0) j = (r - a) / m;
else j = (r - a - m + 1) / m;
cout << j - i + 1 << endl;
return 0;
}
abc 331 B
// 离谱的很,没看出来是暴力
// milk哈哈
#include <iostream>
using namespace std;
int n, m, l, s;
int main()
{
cin >> n >> s >> m >> l;
int ans = 1e9;
for (int i = 0; i < 20; i ++ )
for (int j = 0; j < 15; j ++)
for (int k = 0; k < 10; k ++)
if (a * 6 + b * 8 + c * 12 >= n)
ans = min(ans, i * s + j * m + k * l);
cout << ans << endl;
return 0;
}
abc 330 B
考验读题能力