http://bailian.openjudge.cn/tm201602/
#include
using namespace std;
const int MAX = 105;
int x_a[MAX];
int x_b[MAX];
int N, NA, NB;
int main()
{
cin >> N >> NA >> NB;
for(int i=0; i> x_a[i];
for(int i=0; i> x_b[i];
int a_beat_b_num = 0;
int b_beat_a_num = 0;
for(int i=0; i b_beat_a_num)
cout << "A" << endl;
else if(a_beat_b_num == b_beat_a_num)
cout << "draw" << endl;
else
cout << "B" << endl;
return 0;
}
#include
using namespace std;
char to_lower(char A)
{
if(A >= 'A' && A <='Z')
{
return A + ('a'-'A');
}
return A;
}
int main()
{
char A;
string s1, s2;
getline(cin, s1);
getline(cin, s2);
int l1 = s1.length();
int l2 = s2.length();
int p1 = 0;
int p2 = 0;
int flag = 1;
while(p1
#include
using namespace std;
int a[105][105];
int main()
{
int m, n;
cin >> m >> n;
for(int i=0; i> a[i][j];
for(int j=0; j=0; i--)
{
if(i == m-1)
cout << a[i][j];
else
cout << " " << a[i][j];
}
cout << endl;
}
return 0;
}
#include
#include
using namespace std;
const int MAX = 9;
char grad[MAX][MAX];
int flag[MAX][MAX];
int ans;
int n, k;
void dfs(int find_num, int x, int y)
{
//cout << endl;
//cout << "before find_num: " << find_num << endl;
//cout << x << " " << y << endl;
if(find_num == k)
{
ans++;
return;
}
for(int i=x; i> n >> k)
{
if(n == -1 && k == -1)
return 0;
for(int i=0; i> grad[i][j];
ans = 0;
memset(flag, -1, sizeof(flag));
dfs(0,0,0);
cout << ans << endl;
}
return 0;
}
不明白自己代码为什么Wa了
#include
using namespace std;
const int MAX = 10000+1;
const int MAXSUM = 10000*10000+4;
int a[MAX];
bool dp[2][MAXSUM];
int N, K;
int main()
{
cin >> N >> K;
int M = 0;
for(int i=1; i<=N; i++){
cin >> a[i];
if(a[i] < 0)
{
a[i] = - a[i];
}
M += a[i];
}
for(int i=0; i<=M; i++)
dp[0][i] = false;
dp[0][0] = true;
for(int i=1; i<=N; i++)
{
for(int j=0; j<=M; j++)
{
if((j-a[i]>=0 && dp[(i-1)&1][j-a[i]]) || dp[(i-1)&1][j+a[i]])
dp[i&1][j] = true;
else
dp[i&1][j] = false;
}
}
int flag = 0;
for(int i=0; i<=M; i++)
{
if(dp[N&1][i] && i % K == 0)
{
flag = 1;
break;
}
}
if(flag)
cout << "Divisible" << endl;
else
cout << "Not divisible" << endl;
return 0;
}
AC 代码:
#include
#include
#include
using namespace std;
int n,k;
int a[10010];
bool dp[10010][110];// dp[i][j] = true 表示处理到第 i 个数对 k 取余为 j 是成立的
int main()
{
while(~scanf("%d %d",&n,&k))
{
memset(dp,false,sizeof(dp));
for(int i=1;i<=n;i++)
scanf("%d",&a[i]);
dp[1][( (a[1] % k) + k ) % k]=true;// 这里用了同余定理 (a+b)%c=(a%c+b%c)%c,a[1]对 k 取余为 ( (a[1] % k) + k ) % k是显然成立的
for(int i=2;i<=n;i++)
{
for(int j=0;j
#include
#include
using namespace std;
const int MAX = 17;
const int INF = MAX * MAX + 100;
int flip[MAX][MAX];
int base[MAX][MAX];
int n;
int dir[4][2] = {{0,1},{-1,0},{0,-1},{0,0}};
int is_white(int x, int y)
{
int flip_num = 0;
for(int i=0; i<4; i++)
{
int nx = x + dir[i][0];
int ny = y + dir[i][1];
if(nx < 0 || nx >= n || ny < 0 || ny >= n)
continue;
flip_num += flip[nx][ny];
}
if((base[x][y] + flip_num) % 2)
return 1;
return 0;
}
int main()
{
cin >> n;
char ch;
for(int i=0; i> ch;
if(ch == 'w')
base[i][j] = 1;
else
base[i][j] = 0;
}
}
int ans = INF;
for(int s=0; s<(1<> i) & 1;
}
for(int r=1; r