#include
#include
#include
#include
#include
using namespace std;
int main()
{
int T;
for(scanf("%d",&T);T--;){
int a,b,c,d;
scanf("%d %d %d %d",&a,&b,&c,&d);
if(a<85||d<85||b<55||c<55||a+b+c+d<305){
printf("C\n");
}else{
if(a+b+c+d>=370){
printf("A\n");
}else{
printf("B\n");
}
}
}
return 0;
}
#include
#include
#include
#include
#include
using namespace std;
char s[55];
int num[18]= {0,7, 9, 10, 5, 8, 4, 2, 1, 6, 3, 7, 9, 10, 5, 8, 4, 2};
int to[11]= {1,0,'X'-'0',9,8,7,6,5,4,3,2};
void check()
{
int sum=0;
for(int i=1; i<=17; i++)
{
sum+=num[i]*(s[i]-'0');
}
int a=s[18]-'0';
sum=sum%11;
if(to[sum]==s[18]-'0')
{
printf("Accepted\n");
}
else
{
printf("Sorry\n");
}
}
int main()
{
int n;
while(~scanf("%d",&n))
{
int year,month,day;
scanf("%d-%d-%d",&year,&month,&day);
for(int i=1; i<=n; i++)
{
scanf("%s",s+1);
int y,m,d;
y=(s[7]-'0')*1000+(s[8]-'0')*100+(s[9]-'0')*10+s[10]-'0';
m=(s[11]-'0')*10+s[12]-'0';
d=(s[13]-'0')*10+s[14]-'0';
int fy=y+18;
if(year>fy)
{
check();
}
else if(fy==year)
{
if(month>m)
{
check();
}
else if(month==m)
{
if(day>=d)
{
check();
}
else
{
printf("Sorry\n");
}
}
else
{
printf("Sorry\n");
}
}
else
{
printf("Sorry\n");
}
}
}
return 0;
}
#include
#include
#include
#include
#include
using namespace std;
#define LL long long
int main()
{
LL n,m;
while(~scanf("%lld %lld",&n,&m)){
LL t1,t2,t3,t4;
scanf("%lld %lld %lld %lld",&t1,&t2,&t3,&t4);
LL ans1=0;
ans1=fabs(n-m)*t1+t2+t2+t3+fabs(n-1)*t1;
LL ans2=fabs(n-1)*t4;
printf("%lld\n",min(ans1,ans2));
}
return 0;
}
#include
#include
#include
#include
#include
using namespace std;
#define LL long long
const int maxn = 1e6+33;
LL gcd(LL a,LL b)
{
if(b==0) return a;
return gcd(b,a%b);
}
int main()
{
LL n,m,k;
while(~scanf("%lld %lld %lld",&m,&n,&k)){
LL a=1;
for(int i=1;i<=k;i++) a<<=1;
LL fm=a*n+m;
LL fz=m;
LL now = gcd(fm,fz);
while(now!=1){
fm=fm/now;
fz=fz/now;
now=gcd(fm,fz);
}
printf("%lld/%lld\n",fz,fm);
}
return 0;
}
找规律题。
#include
#include
#include
#include
#include
using namespace std;
#define LL long long
const int maxn = 333;
const LL mod = 1e9+7;
LL a[maxn];
LL num[maxn];
int main()
{
num[1]=1;
for(int i=2;i<=120;i++){
num[i]=num[i-1]*2%mod;
}
LL n;
while(~scanf("%lld",&n)){
for(int i=1;i<=n+1;i++){
scanf("%lld",&a[i]);
}
LL ans=0;
for(int i=1;i<=n;i++)
(ans+=mod+a[i]*num[n]%mod)%mod;
(ans+=mod+a[n+1])%mod;
printf("%lld\n",ans%mod);
}
return 0;
}
#include
#include
#include
#include
#include
#include
using namespace std;
#define LL long long
const int maxn = 100000+33;
int num[maxn+44];
struct node
{
int a,b;
int num;
}a[maxn];
int n;
int lowbit(int x)
{
return x&(-x);
}
void add(int x)
{
for(int i=x;i<=n;i+=lowbit(i))
num[i]++;
}
int query(int x)
{
int ans=0;
for(int i=x;i>=1;i-=lowbit(i)) ans+=num[i];
return ans;
}
int main()
{
while(~scanf("%d",&n)){
int cnt=0;
memset(num,0,sizeof num);
for(int i=1;i<=n/2;i++){
++cnt;
scanf("%d %d",&a[cnt].a,&a[cnt].b);
a[cnt].num=min(a[cnt].a,a[cnt].b);
}
LL ans=0;
for(int i=1;i<=cnt;i++){
add(a[i].num);
ans+=1LL*query(n)-1LL*query(a[i].num);
if(a[i].b
#include
#include
#include
#include
#include
#include
using namespace std;
#define LL long long
const int maxn = 111+33;
int mp[maxn][maxn];
int ans,n;
struct node
{
int len;
int h;
node(int l,int hh):
len(l),h(hh){}
};
void dfs(int x,int y)
{
if((n-x+1)*(n-y+1)<=ans) return;
stack q;
int pre=-1;
int hh;
for(int i=x;i<=n;i++){
if(pre!=-1){
if(pre^mp[i][y]!=1) break;
}
hh=i;
int now=mp[i][y];
pre=now;
int len=1;
for(int j=y+1;j<=n;j++){
if(now^mp[i][j]==1){
now=mp[i][j];
len++;
}else{
break;
}
}
node b(len,i);
while(!q.empty()&&q.top().len>len){
node a=q.top();
q.pop();
b.h=a.h;
ans=max(ans,(i-a.h)*a.len);
}
q.push(b);
}
while(!q.empty()){
node a=q.top();
q.pop();
ans=max(ans,(hh-a.h+1)*a.len);
}
}
int main()
{
int T;
scanf("%d",&T);
while(T--){
scanf("%d",&n);
ans=1;
for(int i=1;i<=n;i++){
for(int j=1;j<=n;j++){
scanf("%d",&mp[i][j]);
}
}
for(int i=1;i<=n;i++){
for(int j=1;j<=n;j++){
dfs(i,j);
}
}
printf("%d\n",ans);
}
return 0;
}
状压
#include
#include
#include
#include
#include
#include
using namespace std;
#define LL long long
const int maxn = 111+33;
int num[2000];
char s[123];
int main()
{
int n;
while(~scanf("%d",&n)){
memset(num,0,sizeof num);
for(int i=1;i<=n;i++){
int now=0;
scanf("%s",s);
int l=strlen(s);
for(int i=0;i0){
int m=num[i]+num[j];
ans+=1LL*num[i]*num[j];
}
}
}
printf("%lld\n",ans);
}
return 0;
}
#include
#include
#include
#include
#include
using namespace std;
#define LL long long
const int maxn = 100000+44;
LL a[maxn];
LL b[maxn];
bool cmd(LL aa,LL bb)
{
return aa>bb;
}
int main()
{
int n,m;
scanf("%d%d",&n,&m);
for(int i=1; i<=n; i++) scanf("%lld",&a[i]);
for(int i=1; i<=m; i++) scanf("%lld",&b[i]);
sort(a+1,a+1+n,cmd);
sort(b+1,b+1+m,cmd);
int num=min(n,m);
LL ans=0;
for(int i=1; i<=num; i++)
{
ans+=(1LL*a[i]*1LL*b[i]);
}
printf("%d %lld\n",num,ans);
return 0;
}
说实话大二去参加别人的新生赛,心情是很复杂的。
但是竟然ak了也是没想到