枚举
2024-06-26 20:43:27
发布于:上海
18阅读
0回复
0点赞
结构体暴力枚举。输出细节很多,尤其是在没有数的时候,要输出 。
#include<cstdio>
#include<cstring>
using namespace std;
#define ll long long
#define ull unsigned long long
namespace io{
const int size=(1<<20)+1;
char buf[size],*p1=buf,*p2=buf;
char buffer[size];
int op1=-1;
const int op2=size-1;
inline char readchar() {
if(p1!=p2) {
return *p1++;
}
return p1==(p2=(p1=buf)+fread(buf,1,size-1,stdin))?EOF:*p1++;
}
inline void flush() {
fwrite(buffer,1,op1+1,stdout),op1=-1;
}
inline void writechar(const char &x) {
if(op1==op2) flush();
buffer[++op1]=x;
}
#ifndef ONLINE_JUDGE
#define gc getchar
#else
#define gc readchar
#endif
#define pc writechar
#define el pc(10)
#define sp pc(32)
inline int readi(){
int x=0;bool w=0;
char ch=gc();
while(ch<'0'||ch>'9'){
if(ch==EOF) return EOF;
if(ch=='-') w=1;
ch=gc();
}
while(ch>='0'&&ch<='9'){
x=(x<<3)+(x<<1)+(ch^48);
ch=gc();
}
return w?-x:x;
}
inline ll readl(){
ll x=0;bool w=0;
char ch=gc();
while(ch<'0'||ch>'9'){
if(ch=='-') w=1;
ch=gc();
}
while(ch>='0'&&ch<='9'){
x=(x<<3)+(x<<1)+(ch^48);
ch=gc();
}
return w?-x:x;
}
inline ll readull(){
ll x=0;
char ch=gc();
while(ch>=32){
if(ch>='0'&&ch<='9')x=(x<<3)+(x<<1)+(ch^48);
ch=gc();
}
if(ch==-1) x=-x;
return x;
}
inline void reads(char* s){
char ch=gc();
while(ch>32) *(s++)=ch,ch=gc();
*s=0;
}
inline void readline(char* s){
char ch=gc();
while(ch>=32) *(s++)=ch,ch=gc();
*s=0;
}
inline void clearline(){
char ch=gc();
while(ch>=32) ch=gc();
}
void write(int x){
if(x<0) pc('-'),x=-x;
if(x>9) write(x/10);
pc((x%10)^48);
}
void write(ll x){
if(x<0) pc('-'),x=-x;
if(x>9) write(x/10);
pc((x%10)^48);
}
void write(ull x){
if(x>9) write(x/10);
pc((x%10)^48);
}
void writes(const char* s){
const char*pt=s;
while(*pt!=0)pc(*pt++);
}
};// io
using namespace io;
const struct{
char s[10];
int d;
} num[26]={
{"one",1},
{"two",2},
{"three",3},
{"four",4},
{"five",5},
{"six",6},
{"seven",7},
{"eight",8},
{"nine",9},
{"ten",10},
{"eleven",11},
{"twelve",12},
{"thirteen",13},
{"fourteen",14},
{"fifteen",15},
{"sixteen",16},
{"seventeen",17},
{"eighteen",18},
{"nineteen",19},
{"twenty",20},
{"a",1},
{"both",2},
{"another",1},
{"first",1},
{"second",2},
{"third",3},
};
int main(){
char a[105],b[105],c[105],d[105],e[105],f[105];
reads(a);reads(b);reads(c);reads(d);reads(e);reads(f);
int ans[6]={0};
for(int i=0;i<26;i++){
if(!strcmp(num[i].s,a))ans[0]=num[i].d*num[i].d%100;
if(!strcmp(num[i].s,b))ans[1]=num[i].d*num[i].d%100;
if(!strcmp(num[i].s,c))ans[2]=num[i].d*num[i].d%100;
if(!strcmp(num[i].s,d))ans[3]=num[i].d*num[i].d%100;
if(!strcmp(num[i].s,e))ans[4]=num[i].d*num[i].d%100;
if(!strcmp(num[i].s,f))ans[5]=num[i].d*num[i].d%100;
}
int ff=0;
for(int i=0;i<6;i++){
if(ans[i]){
if(ff){
pc(ans[i]/10^48);
pc(ans[i]%10^48);
}
else{
write(ans[i]);
ff=1;
}
}
}
if(!ff)pc(48);
flush();return 0;
}
这里空空如也
有帮助,赞一个