AC代码贴板
A. I Scream
#include<iostream>
#include<cstdio>
#include<cstring>
#include<string>
#include<cmath>
#include<algorithm>
#include<set>
#include<fstream>
#include<stack>//别问我为啥不用万能库,问就是用的MSVC,4996也是这个
typedef long long LL;
typedef unsigned long long uLL;
#pragma warning (disable:4996)
using namespace std;
uLL Judge(uLL a, uLL b)
{
if (a >= 15 && b >= 8)
{
return 1;
}//type1
if (a >= 10 && b >= 3)
{
return 2;
}//type2
if (a >= 3)
{
return 3;
}//type3
return 4;
}
int main()
{
uLL milkSoildsNotFat, milkFat;
uLL type = 0;
cin >> milkSoildsNotFat >> milkFat;
uLL milkSoild = milkSoildsNotFat + milkFat;
type = Judge(milkSoild, milkFat);
cout << type;
return 0;
}
//不会吧,不会真的有人看不懂驼峰法吧,不会吧不会吧(
B.Job Assignment
#include<iostream>
#include<cstdio>
#include<cstring>
#include<string>
#include<cmath>
#include<algorithm>
#include<set>
#include<fstream>
#include<stack>
typedef long long LL;
typedef unsigned long long uLL;
#pragma warning (disable:4996)
using namespace std;
int main()
{
int workers;
cin >> workers;
int timeOfQuestionA[1100] = {};
int timeOfQuestionB[1100] = {};
int timeOfSolution1[1100] = {};
int timeOfSolution2 = 99999999;
for (int i = 0; i < workers; i++)
{
cin >> timeOfQuestionA[i] >> timeOfQuestionB[i];
timeOfSolution1[i] = timeOfQuestionA[i] + timeOfQuestionB[i];
}
sort(timeOfSolution1, timeOfSolution1 + workers);
for (int i = 0; i < workers; i++)
{
for (int j = 0; j < workers; j++)
{
if (i == j)
{
continue;
}
else
{
int cache = max(timeOfQuestionA[i], timeOfQuestionB[j]);
if (cache < timeOfSolution2)
{
timeOfSolution2 = cache;
}
}
}
}
int minNum = 0;
if (timeOfSolution1[0] < timeOfSolution2)
{
minNum = timeOfSolution1[0];
}
else
{
minNum = timeSolution2;
}
cout << minNum;
return 0;
}
一些别的
关于C题
之前的代码(RE的!)
#include<iostream>
#include<cstdio>
#include<cstring>
#include<string>
#include<cmath>
#include<algorithm>
#include<set>
#include<fstream>
#include<stack>
typedef long long LL;
typedef unsigned long long uLL;
using namespace std;
int main()
{
int n;
cin >> n;
int out = 0;
static int nums[100100] = {};
for (int i = 0; i < n; i++)
{
cin >> nums[i];
}
for (int i = 1; i < n; i++)
{
for (int j = 0; j < i; j++)
{
out += (nums[i] - nums[j]) * (nums[i] - nums[j]);
}
}
cout << out;
return 0;
}
也不知道为啥错了
某国内大佬的AC代码
#include<cstdio>
#include<cstring>
#include<algorithm>
using namespace std;
typedef long long ll;
int n,a[1000005];
ll ans;
int main()
{
scanf("%d",&n);
for(int i=1;i<=n;i++)
scanf("%d",&a[i]);
int sum=0;
for(int i=1;i<=n;i++)
{
ans+=1ll*(n)*a[i]*a[i];
sum+=a[i];
}
ans-=1ll*sum*sum;
printf("%lld\n",ans);
return 0;
}
看不懂欸,是我见的少了(