只会A、B、C
A 意思就是给出一个数,问你可以分成多少个3,因为3 = 1 + 2,这样交替给就行了,有余数再加1就解决。
#include <iostream>
#include <cstring>
#include <cstdio>
#include <vector>
using namespace std;
const int MAX = 505;
inline void file()
{
freopen("D:\\zz.txt", "r", stdin);
freopen("D:\\out.txt", "w", stdout);
}
int main()
{
//file();
int n;
while (scanf("%d", &n) != EOF)
{
int res = 0;
res = (n / 3) * 2 + ((n % 3 == 0) ? 0 : 1);
printf("%d\n", res);
}
return 0;
}
#include <iostream>
#include <cstring>
#include <cstdio>
#include <vector>
#include <map>
using namespace std;
const int MAX = 505;
map<int, int> cnt;
inline void file()
{
freopen("D:\\zz.txt", "r", stdin);
freopen("D:\\out.txt", "w", stdout);
}
int main()
{
//file();
int n;
char str[100005];
int num[100005];
while (scanf("%d", &n) != EOF)
{
memset(num, 0, sizeof(num));
cnt.clear();
scanf("%s", str);
for (int i = 0; i < n; ++i)
scanf("%d", &num[i]);
int res = 0;
bool vis = false;
bool flag = false;
for (int i = 0; i < n;)
{
if (str[i] == '<')
{
i -= num[i];
cnt[i]++;
if (i < 0 || i > n - 1)
{
flag = true;
break;
}
if (cnt[i] > 1)
{
vis = true;
break;
}
}
else if (str[i] == '>')
{
i += num[i];
cnt[i]++;
if (i < 0 || i > n - 1)
{
flag = true;
break;
}
if (cnt[i] > 1)
{
vis = true;
break;
}
}
}
if (flag)
printf("FINITE\n");
else if (vis)
printf("INFINITE\n");
}
return 0;
}
#include <iostream>
#include <cstring>
#include <cstdio>
#include <vector>
#include <map>
using namespace std;
const int MAX = 505;
//vector<int> t[5];
int arr[105][105];
int n, m, q;
struct NODE
{
int t_x, t_y;
NODE(int x = 0, int y = 0)
: t_x(x), t_y(y) {}
}node[105][105];
inline void file()
{
freopen("D:\\zz.txt", "r", stdin);
freopen("D:\\out.txt", "w", stdout);
}
void swap_x(int t)
{
NODE tmp = node[t][1];
for (int i = 1; i <= m - 1; ++i)
{
node[t][i] = node[t][i + 1];
}
node[t][m] = tmp;
}
void swap_y(int t)
{
NODE tmp = node[1][t];
for (int i = 1; i <= n - 1; ++i)
{
node[i][t] = node[i + 1][t];
}
node[n][t] = tmp;
}
int main()
{
//file();
scanf("%d%d%d", &n, &m, &q);
for (int i = 1; i <= n; ++i)
{
for (int j = 1; j <= m; ++j)
{
node[i][j] = NODE(i, j);
}
}
int type, pos;
int tmp_x, tmp_y, tmp_val;
while (q--)
{
scanf("%d", &type);
if (type == 1)
{
scanf("%d", &pos);
swap_x(pos);
continue;
}
else if (type == 2)
{
scanf("%d", &pos);
swap_y(pos);
continue;
}
else if (type == 3)
{
scanf("%d%d%d", &tmp_x, &tmp_y, &tmp_val);
arr[node[tmp_x][tmp_y].t_x][node[tmp_x][tmp_y].t_y] = tmp_val;
}
}
for (int i = 1; i <= n; ++i)
{
for (int j = 1; j <= m; ++j)
{
printf("%d ", arr[i][j]);
}
printf("\n");
}
return 0;
}