1.被污染的支票


#include <iostream>
#include <vector>
#include <map>
#include <algorithm>
using namespace std;
int main()
{
int n;
cin>>n;
vector<int>L;
map<int,int>mp;
bool ok=0;
int num;
for(int i=1;i<=n;i++)
{
cin>>num;
if(mp[num]==1)ok=1;
else
{
mp[num]=1;
L.push_back(num);
}
}
sort(L.begin(),L.end());
int x=L.back()*2;//?????
vector<int>L2;
for(int i=2;i<x;i++)
{
if(x%i==0)L2.push_back(i);
}
if(L!=L2)ok=1;
if(ok)
{
cout<<-1<<endl;
}
else
{
cout<<x<<endl;
}
return 0;
}
2.日期统计

#include <iostream>
#include <vector>
#include <map>
using namespace std;
int main()
{
int ans=0;
int num[100]={5, 6, 8, 6, 9, 1, 6, 1, 2, 4,
9, 1, 9, 8, 2, 3, 6, 4, 7, 7,
5, 9, 5, 0, 3, 8, 7, 5, 8, 1,
5, 8, 6, 1, 8, 3, 0, 3, 7, 9,
2, 7, 0, 5, 8, 8, 5, 7, 0, 9,
9, 1, 9, 4, 4, 6, 8, 6, 3, 3,
8, 5, 1, 6, 3, 4, 6, 7, 0, 7,
8, 2, 7, 6, 8, 9, 5, 6, 5, 6,
1, 4, 0, 1, 0, 0, 9, 4, 8, 0,
9, 1, 2, 8, 5, 0, 2, 5, 3, 3};
int days[13]={0,31,28,31,30,31,30,31,31,30,31,30,31};
for(int mon=1;mon<=12;mon++)
{
for(int day=1;day<=days[mon];day++)
{
int temp[8]={2,0,2,3,mon/10,mon%10,day/10,day%10};
int k=0;
for(int i=0;i<100;i++)
{
if(num[i]==temp[k])
{
k++;
}
if(k==8)
{
ans++;
break;
}
}
}
}
cout<<ans<<endl;
return 0;
}
3.01串的熵

#include <iostream>
#include <cmath>
using namespace std;
int main()
{
int n=23333333;
for(int i=0;i<=n/2;i++)//0的次数
{
double a=(i*1.0)/n;
double b=((n-i)*1.0)/n;
double ans=0;
ans-=(a*log2(a)*i+b*log2(b)*(n-i));
if(fabs(ans-11625907.5798)<0.0001)
{
cout<<i<<endl;
break;
}
}
return 0;
}
(注意浮点数,double,以及比较大小时使用1e-4)
4.冶炼金属

最低0.47元/天 解锁文章

被折叠的 条评论
为什么被折叠?



