1.HDU - 6225 https://vjudge.net/contest/329277#problem/A
题意:
给出四个数(小于等于!!!2^62 !!!),输出这四个数的和
题解:
队友因为long long wa了一发,我因为unsigned long long wa了一发。
最后用unsigned long long + 四个如果都是2^62必须手动输出2^64过了
记住! long long的数据范围是2^63-1 unsigned long long 的数据范围是2^64-1
代码:
#include <cstdio>
#include <iostream>
#define ll unsigned long long
using namespace std;
ll a[5];
int main()
{
int t;
cin>>t;
while(t--)
{
ll ans = 0,cnt = 0 ;
for(int i=0;i<4;i++){
cin>>a[i];
ans += a[i];
if(a[i] == 4611686018427387904){
cnt++;
}
}
if(cnt == 4){
cout<<"18446744073709551616"<<endl;
continue ;
}
cout<<ans<<endl;
}
return 0;
}2.HDU - 6227 https://vjudge.net/contest/329506#problem/B
题意:
给出n只兔子当前的位置,每只兔子可以跳到其余的任意俩只兔子的位置中间(仅当那俩只兔子之间的距离大于1),一个位置仅能有一只兔子,问你兔子最多可以跳多少次。
题解:
直接考虑最前面的兔子和最后的兔子,可以想象,最后肯定是所有的兔子在连续的位置才不能存在可以跳动的兔子
代码:
#include <cstdio>
#include <iostream>
#define ll long long
using namespace std;
ll a[505],pre[505];
int main()
{
int t,n;
cin>>t;
while(t--)
{
ll ans = 0;
cin>>n;
for(int i=1;i<=n;i++){
cin>>a[i];
if(i >= 2)
pre[i] = a[i] - a[i-1];
}
ll maxx = max(pre[2],pre[n]);
for(int i=3;i<n;i++){
if(pre[i] >= 2)
ans += pre[i]-1;
}
if(maxx >= 2){
cout<<ans + maxx -1<<endl;
continue ;
}
cout<<ans<<endl;
}
return 0;
}3.HDU - 6222 https://vjudge.net/contest/329506#problem/C
题意:
已知一种三角形符合 n-1 ,n,n+1是三角形的三条边而且三角形的面积是整数!给你一个小于等于10^30的数字m,问你第一个大于等于m且符合m-1,m,m+1的三角形的m
题意:
打表已知三角形的三条边求面积公式,找规律,发现序列是4,14,52,194,724,2702,10084;
满足ai = 4*ai-1 - ai-2 ,用java大数直接写
打表代码:
#include <cstdio>
#include <iostream>
#include <cmath>
#define ll long long
using namespace std;
int main()
{
int t,n;
for(int i=4;i<=30000;i++)
{
double a = i-1;
double b = i;
double c = i+1;
double cosA = (double)(b*b + c*c - a*a)/(2*b*c);
double sinA = (double)sqrt(1 - cosA*cosA);
double S = (double)b*c*sinA/2;
int s = (int)S;
if(S - s <= 1e-1000){
cout<<i<<endl;
}
}
return 0;
}4.HDU - 6223 https://vjudge.net/contest/329506#problem/J
##题意 :

京公网安备 11010502036488号