微众java编程题也太太太太太水了
写选择写了8min,7:45min就a了全3道题,这是真实存在的笔试吗,让我这种菜鸡真真切切的体会到了ak的快乐
#include
#include
#include
#include
#define maxn 1001
using namespace std;
int main() {
int n,m,a,b;
cin >> n >> m >> a >> b;
int ans = 999999999;
for (int i = n; i > 0; --i) {
int t = m%i;
if(m != 0 && t == 0)
t = i;
//cout << t << endl;
if(m > i && i < n)
t = i;
int temp = (i-t)*b + (n-i)*a;
//cout << temp << endl;
ans = min(ans,temp);
}
ans = min(ans,a*n);
cout << ans;
}第一题简单算术 有n个小朋友 m个礼物 买个礼物b块钱 包个红包a块钱 红包把小朋友请走(可以带着礼物走)没被请走的小朋友礼物要一样多 问最少多少钱
#include <iostream>
#include <cstdio>
#include <cstring>
using namespace std;
int main(){
int n;
cin >> n;
for(int i = 0; i < n; i ++) {
int asd[26];
memset(asd,0,sizeof(asd));
string s;
cin >> s;
for(int i = 0; i < s.size(); i++){
asd[s[i]-'a']++;
}
int ans = 0;
for(int i = 0; i < 26; i++){
if(asd[i] & 1)
ans ++;
}
if(ans > 0)
ans -= 1;
if(ans == 0 || ans %2 == 0)
cout << "Cassidy";
else
cout << "Eleanore";
cout << endl;
}
} 第二题 语法题 给个字符串(只包含小写字母) 两个小女孩先后取 哪个小女孩能先把字符串任意排列成一个回文串就赢了 输出赢的小女孩 奇偶+特判
#include <iostream>
#include <cstdio>
#include <cstring>
#include <algorithm>
#define maxn 1001
using namespace std;
struct ka{
int cost,weight;
ka() = default;
ka(int cost, int weight) {
this -> cost = cost;
this -> weight = weight;
}
}kas[maxn];
bool cmp(const ka& a, const ka &b){
if(a.cost != b.cost)
return a.cost > b.cost;
return a.weight > b.weight;
}
int main() {
int n;
cin >> n;
for(int i = 0; i < n; i ++){
int a,b;
cin >> a >> b;
kas[i] = ka(b,a);
}
sort(kas,kas+n,cmp);
int k = 1, i = 0;
int ans = 0;
while(k && i != n){
int cost = kas[i].cost;
int weight = kas[i].weight;
k += (cost-1);
ans += weight;
i++;
}
cout << ans;
}第三题抽卡 一张卡抽了这张卡可以增加b次抽卡次数 价值为a 初始能抽一张卡 问能得到价值最大是多少 简单简单贪心
#微众##微众银行##笔试题目#


