POJ openjudge 个人测试 #2
事情比较多QAQ
1295.I hate SPAM, but some people love it
直接dfs。。。然后用一堆stl
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 |
#include<set> #include<map> #include<cmath> #include<ctime> #include<queue> #include<cstdio> #include<vector> #include<cstring> #include<cstdlib> #include<iostream> #include<algorithm> #define mod 1000000007 #define inf 1000000000 #define eps 1e-1 #define ll long long using namespace std; ll read() { ll x=0,f=1;char ch=getchar(); while(ch<'0'||ch>'9'){if(ch=='-')f=-1;ch=getchar();} while(ch>='0'&&ch<='9'){x=x*10+ch-'0';ch=getchar();} return x*f; } int n,x,t1,t2; string a1,a2,a3; vector<int>ve[25]; vector<string>ans[25]; string nam[25]; bool vis[25]; void solve(int x) { if(vis[x])return; vis[x]=1; if(ve[x].size()<t1)ans[x].push_back(a1); else if(ve[x].size()<t2)ans[x].push_back(a2); else ans[x].push_back(a3); for(int i=0;i<ve[x].size();i++) solve(ve[x][i]); } int main() { while(1) { n=read(); if(n==0)return 0; for(int i=1;i<=n;i++) { x=read(); while(x) { ve[i].push_back(x); x=read(); } } x=read(); while(x) { t1=read();t2=read(); cin>>a1>>a2>>a3; memset(vis,0,sizeof(vis)); solve(x); x=read(); for(int i=1;i<=n;i++) if(!vis[i])ans[i].push_back(a1); } for(int i=1;i<=n;i++)cin>>nam[i]; for(int i=1;i<=n;i++) { cout<<nam[i]<<": "; for(int j=0;j<ans[i].size();j++) cout<<ans[i][j]<<' '; cout<<endl; } for(int i=1;i<=n;i++) ve[i].clear(),ans[i].clear(); } return 0; } |
1941.The Sierpinski Fractal
递归QAQ
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 |
#include<set> #include<map> #include<cmath> #include<ctime> #include<queue> #include<cstdio> #include<vector> #include<cstring> #include<cstdlib> #include<iostream> #include<algorithm> #define mod 1000000007 #define inf 1000000000 #define eps 1e-1 #define ll long long using namespace std; ll read() { ll x=0,f=1;char ch=getchar(); while(ch<'0'||ch>'9'){if(ch=='-')f=-1;ch=getchar();} while(ch>='0'&&ch<='9'){x=x*10+ch-'0';ch=getchar();} return x*f; } int n,t; string s[2]={" /\\ ","/__\\"}; char ans[3005][3005]; void solve(int a,int b,int t) { if(t==2) { for(int i=0;i<s[0].length();i++) { ans[a][i+b+1]=s[0][i]; ans[a+1][i+b+1]=s[1][i]; } return; } solve(a,b+t/2,t/2); solve(a+t/2,b,t/2); solve(a+t/2,b+t,t/2); } int main() { while(scanf("%d",&n)) { t=1; if(!n)return 0; for(int i=1;i<=n;i++)t*=2; for(int i=0;i<t;i++) for(int j=1;j<=2*t;j++) ans[i][j]=' '; solve(0,0,t); for(int i=0;i<t;i++) { for(int j=1;j<=2*t;j++) cout<<ans[i][j]; cout<<endl; } cout<<endl; } return 0; } |
1663.Number Steps
模拟用map把图直接存下来。。。
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 |
#include<set> #include<map> #include<cmath> #include<ctime> #include<queue> #include<cstdio> #include<vector> #include<cstring> #include<cstdlib> #include<iostream> #include<algorithm> #define mod 1000000007 #define inf 1000000000 #define eps 1e-1 #define ll long long using namespace std; ll read() { ll x=0,f=1;char ch=getchar(); while(ch<'0'||ch>'9'){if(ch=='-')f=-1;ch=getchar();} while(ch>='0'&&ch<='9'){x=x*10+ch-'0';ch=getchar();} return x*f; } int n; map<int,int>mp[5005]; void pre() { mp[0][0]=1; mp[1][1]=2; mp[2][0]=3; mp[3][1]=4; for(int i=2;i<=5000;i++) mp[i][i]=mp[i-2][i-2]+4; for(int i=4;i<=5000;i++) mp[i][i-2]=mp[i-2][i-4]+4; } int main() { pre(); n=read(); for(int i=1;i<=n;i++) { int x=read(),y=read(); if(!mp[x][y])puts("No Number"); else printf("%d\n",mp[x][y]-1); } return 0; } |
1663.Number Steps那道题貌似是错的吧。。。
后两个代码是一样的什么鬼
orzzzzz 吴一凡