题目是看这个的
https://blog.csdn.net/qq_37640597/article/details/79772948
又看到这个说是软院2018,
https://www.cnblogs.com/xym4869/p/8707302.html
无所谓啦反正是2018的
人工智能的笔试题我可怎么办,不行的话通信和编译我可怎么办,找不到什么人工智能的真题可怎么办,这两天专业英语也没看……
如果老师问什么学科基础知识答不出来可怎么办……
Problem A
#include<iostream>
#include<cstring>
#include<cmath>
using namespace std;
typedef long long ll;
int a[33];
int main(){
int t;
cin>>t;
while(t--){
ll x,y=0;
cin>>x;
memset(a,0,sizeof(a));
int i=0;
do{
a[i++]=x%2;
x/=2;
}while(x);
for(int j=0;j<i;j++){
if(a[j]) y+=pow(2,i-j-1);
}cout<<y<<endl;
}
return 0;
}
Problem B
#include<iostream>
#include<cstring>
#include<vector>
using namespace std;
const int maxn=110;
char c[4][4]={"001","100","101","111"};
int main(){
int t;
cin>>t;
getchar();
while(t--){
vector<string> ans[6];
char str[maxn];
gets(str);
int num[21],len=strlen(str);
for(int i=0,j=0;i<len;i++,j++) num[j]=str[i]-'0';
for(int i=0;i<len;i++){
if(num[i]==1) ans[0].push_back(c[0]);
else if(num[i]==4) ans[0].push_back(c[2]);
else ans[0].push_back(c[3]);
}
for(int i=0;i<len;i++){
int x=num[i];
if(x==1||x==2||x==3||x==7) ans[1].push_back(c[0]);
else if(x==4||x==0||x==8||x==9) ans[1].push_back(c[2]);
else ans[1].push_back(c[1]);
}
for(int i=0;i<len;i++){
int x=num[i];
if(x==1||x==7) ans[2].push_back(c[0]);
else if(x==0) ans[2].push_back(c[2]);
else ans[2].push_back(c[3]);
}
for(int i=0;i<len;i++){
int x=num[i];
if(x==2) ans[3].push_back(c[1]);
else if(x==0||x==6||x==8) ans[3].push_back(c[2]);
else ans[3].push_back(c[0]);
}
for(int i=0;i<len;i++){
int x=num[i];
if(x==1||x==4||x==7) ans[4].push_back(c[0]);
else ans[4].push_back(c[3]);
}
for(int i=0;i<5;i++){
for(int j=0;j<ans[i].size();j++){
cout<<ans[i][j];
}printf("\n");
}
}
return 0;
}
Problem C 这个题目里面没有说它保证输入的一定是发财数,所以也没有处理,如果输入的不是发财数会输出0
考试我可能会因为不知道合数是素数相乘得到的这一点做复杂吧……基础数学知识还是emmm大一点的题就不要用cin,cout
#include<iostream>
#include<cmath>
#include<map>
#include<cstring>
using namespace std;
const int maxn=10010;
int hash[maxn];
map<int,int> ans;
bool isPrime(int n){
if(n<=1) return false;
for(int i=2;i<=(int)sqrt(1.0*n);i++)
if(n%i==0) return false;
return true;
}
void init(){
memset(hash,0,sizeof(hash));
hash[2]=1;
for(int n=2;n<=10000;n++){
if(isPrime(n)) hash[n]=-1;//素数为-1
else{
for(int i=2;i<=1.0*n/2;i++){
if(hash[i]==-1&&n%i==0) {
if(hash[n/i]!=-1) hash[n]=hash[n/i]+1;
else hash[n]=2;
break;
}
}
}
}
for(int i=2,j=1;i<maxn;i++){
if(hash[i]>=8) ans[i]=j++;
}
}
int main(){
int t,x;
scanf("%d",&t);
init();
while(t--){
scanf("%d",&x);
printf("%d\n",ans[x]);
}
return 0;
}
Problem D
#include<iostream>
#include<cstring>
using namespace std;
const int maxn=100010;
char str[maxn];
int s[maxn],d[maxn];
int main(){
gets(str);
int len=strlen(str);
for(int i=0;i<len;i++)
if(str[i]=='0') s[i]=-1;
else s[i]=1;
d[0]=s[0];
for(int i=1;i<len;i++) d[i]=s[i]+d[i-1];
int max=0;
for(int i=0;i<len;i++){
if(!d[i]) max=i+1;
}printf("%d\n",max);
return 0;
}
全部未经验证,以上。