uva 340
来源:互联网 发布:shake it动作数据 编辑:程序博客网 时间:2024/05/15 15:27
题目大意:
参见题干以及刘汝佳紫书;
基本思路:
模拟,主要是正确理解题意,所谓在两个序列里都出现过的情况就是不管数字本身相不相同,只要在原始序列里和当前输入的猜测序列里都出现过(显然,个数就是min(ori,ans)了),然后这个res剪掉A就是B了;
代码如下:
#include<iostream>
#include<sstream>
#include<iomanip>
#include<algorithm>
#include<string>
#include<vector>
#include<queue>
#include<list>
#include<stack>
#include<map>
#include<set>
#include<cstdio>
#include<cstdlib>
#include<cmath>
#include<cstring>
using namespace std;
typedef long long ll;
typedef long double lb;
typedef pair<int,int> pii;
const int inf= 0x3f3f3f3f;
const double eps= 1e-8;
const int maxn = 1000000+10;
const int mod = 1000000000+7;
const int dx[]={0,0,-1,1};
const int dy[]={1,-1,0,0};
int ori[1000+10];
int ans[1000+10];
int cnt1[11];
int cnt2[11];
int main()
{
int n;
int cas=1;
while(scanf("%d",&n)==1&&n)
{
for(int i=1;i<=n;i++) scanf("%d",&ori[i]);
printf("Game %d:\n",cas++);
while(1)
{
int cnt0=0;
for(int i=1;i<=n;i++)
{
scanf("%d",&ans[i]);
if(ans[i]==0) cnt0++;
}
if(cnt0==n) break;
int A=0,B=0;
memset(cnt1,0,sizeof(cnt1));
memset(cnt2,0,sizeof(cnt2));
for(int i=1;i<=n;i++)
{
cnt1[ori[i]]++;
cnt2[ans[i]]++;
if(ans[i]==ori[i]) A++;
}
for(int i=0;i<=10;i++)
B+=min(cnt1[i],cnt2[i]);
B=B-A;
printf(" (%d,%d)\n",A,B);
}
}
return 0;
}
- UVA 340
- uva 340
- UVa-340
- uva-340
- uva 340
- UVA 340
- uva 340
- UVA-340
- UVA 340
- uva 340
- UVA 340
- UVA 340 (13.07.27)
- uva——340
- UVA - 340 - Mind Hints
- uva 340(检索)
- UVa 340 模拟
- (UVA)340
- uva
- 构造函数析构函数抛出异常
- 【Caffe】源码解析----caffe.proto (转载)
- zunionstore异常:CROSSSLOT Keys in request don't hash to the same slot
- 欧拉函数(转载)
- 封装Ajax
- uva 340
- 英语音节
- java.lang.Cloneable 实现深clone和浅clone
- Spring事务为什么不会自动回滚?Spring事务怎样才会自动回滚?事务自动回滚条件及手动回滚
- 《leetcode》longest-consecutive-sequence
- 循环的嵌套
- git 406
- lua中常用库函数汇总
- java 通过poi 读取Excel 写入sqlser mysql