1258: [CQOI2007]三角形tri

xiaoxiao2021-02-28  122

认真读题(很重要)

然后找规律+乱搞就可以了

#include<cstdio> #include<cstring> #include<iostream> using namespace std; char str[60]; bool h[5]; int g[5][5]; int main() { memset(g,0,sizeof(g)); g[1][3]=4;g[2][2]=4;g[3][1]=4; h[1]=h[2]=h[3]=false; scanf("%s",str); int len=strlen(str); if(str[len-1]=='4') { for(int i=1;i<=3;i++) { for(int j=0;j<len-1;j++) printf("%c",str[j]); printf("%d\n",i); } return 0; } for(int j=len-1;j>=0;j--) { for(int k=1;k<4;k++) if(g[str[j]-'0'][k]&&!h[k]) { h[k]=true; for(int i=0;i<j;i++)printf("%c",str[i]); puts("4"); } } }

转载请注明原文地址: https://www.6miu.com/read-32275.html

最新回复(0)