标签:des style color java os strong io 数据
9 I‘ll shoot the magic arrow several times on the ground, and of course the arrow will leave some holes on the ground. When you connect three holes with three line segments, you may get a triangle. {|It is hole! Common sense!| No Response, Read Problem Statement|don‘t you know what a triangle is?} 1 Case $1: = >$ 5 $/*This is my code printed in proportional font, isn‘t it cool?*/ printf("Definitely it is cooooooool %d\n",4 * 4 * 4 * 4 * 4 * 4 * 4 * 4 * 4 * 4 * 4 * 4 * 4 * 4 * 4 * 4 * 4 * 4);$ 2 $Two space$ and {blue| red} color!
4 4 doge 6
题解及代码:
#include <iostream>
#include <cstdio>
#include <cstring>
#define maxn 1024*1024+20
using namespace std;
char s[maxn],t[maxn];
int main()
{
int n;
memset(t,0,sizeof(t));
while(scanf("%d",&n)!=EOF)
{
getchar();
memset(s,'\0',sizeof(s));
for(int i=0;i<n;i++)
{
gets(t);
strcat(s,t);
}
//cout<<s<<endl;
int len=strlen(s);
__int64 ans=1;
for(int i=0;i<len;i++)
{
if(s[i]=='$')
{
int k=0;
for(i+=1;;i++)
{
if(s[i]=='$')
{
ans*=(k+1);
break;
}
else if(s[i]==' ') k++;
else
{
ans*=(k+1);
if(ans>100000) ans=100001; //没写这句,WA了n次
k=0;
}
}
}
if(ans>100000) break;
if(s[i]=='{')
{
int k=0;
for(i+=1;;i++)
{
if(s[i]=='}')
{
ans*=(k+1);
break;
}
else if(s[i]=='|') k++;
}
}
if(ans>100000) break;
}
if(ans>100000) printf("doge\n");
else printf("%I64d\n",ans);
}
return 0;
}
/*
一道签到体,被自己WA了N次,都已经在怀疑是不是读错题目了,结果是爆精度WA,还是小看了数据啊。
题目分两种情况:1.{} 求出括号中间|的个数为k,ans*=k+1;
2.$$ q求出$$中间连续空格的个数,对于每个连续的空格,ans*=ki;
如果ans>100000,输出doge,否则输出ans。
本人WA是因为在计算$$过程中,可能会爆精度,没有考虑到这一点,提示点在代码中已经注明。
*/hdu 4891 The Great Pan,布布扣,bubuko.com
标签:des style color java os strong io 数据
原文地址:http://blog.csdn.net/knight_kaka/article/details/38295325