ÉèΪÊ×Ò³ ¼ÓÈëÊÕ²Ø

TOP

UVA 825 --Walking on the Safe Side+DP
2015-07-20 17:23:17 À´Ô´: ×÷Õß: ¡¾´ó ÖРС¡¿ ä¯ÀÀ:1´Î
Tags£ºUVA 825 --Walking the Safe Side

´ÓÒ»¸öµã¿ªÊ¼£¬Èç¹ûʼÖÕÖ»ÍùÓұߺÍϱß×ߣ¬ÔòÈç¹ûÄܵ½´ïÓÒϽǾàÀë±Ø¶¨ÊÇ×îСµÄ£¬

ÇÒÎÞÂÛ×ßÄÇÌõ·Ïß¾àÀë¶¼ÊÇÒ»ÑùµÄ¡£


´úÂëÈçÏ£º


#include
   
     #include
    
      #include
     
       using namespace std; char str[100]; int G[1000][1000]; int dp[1000][1000]; int n,m; void input() { gets(str); sscanf(str,"%d %d",&n,&m); memset(G,0,sizeof(G)); for(int ii=1;ii<=n;ii++) { gets(str); int len=strlen(str); int temp=0,i; for(i=0;i
      
       ='0'&&str[i]<='9') temp=temp*10+str[i]-'0'; else break; } int x=temp; temp=0; for(int j=i+1;j<=len;j++) { if(str[j]>='0'&&str[j]<='9') { temp=temp*10+str[j]-'0'; } else if(str[i]==' '||j==len) { G[x][temp]=1; temp=0; } } } } int main() { int t; gets(str); sscanf(str,"%d",&t); while(t--) { gets(str); input(); memset(dp,0,sizeof(dp)); dp[1][1]=1; for(int i=1;i<=n;i++) for(int j=1;j<=m;j++) { if(G[i][j]==1) dp[i][j]=0; else dp[i][j]+=dp[i-1][j]+dp[i][j-1]; } printf("%d\n",dp[n][m]); if(t) printf("\n"); } return 0; } 
      
     
    
   


¡¾´ó ÖРС¡¿¡¾´òÓ¡¡¿ ¡¾·±Ìå¡¿¡¾Í¶¸å¡¿¡¾Êղء¿ ¡¾ÍƼö¡¿¡¾¾Ù±¨¡¿¡¾ÆÀÂÛ¡¿ ¡¾¹Ø±Õ¡¿ ¡¾·µ»Ø¶¥²¿¡¿
·ÖÏíµ½: 
ÉÏһƪ£ºNSDate --- ÈÕÆÚ ÏÂһƪ£ºNSNumber(·â×°»ù±¾Êý¾ÝÀàÐÍ)

ÆÀÂÛ

ÕÊ¡¡¡¡ºÅ: ÃÜÂë: (ÐÂÓû§×¢²á)
Ñé Ö¤ Âë:
±í¡¡¡¡Çé:
ÄÚ¡¡¡¡ÈÝ:

¡¤Spring Boot Java£º (2025-12-26 16:20:19)
¡¤Spring Boot¤ÇHello (2025-12-26 16:20:15)
¡¤Spring ¤Î»ù±¾¤«¤éŒ (2025-12-26 16:20:12)
¡¤C++Ä£°å (template) (2025-12-26 15:49:49)
¡¤C ÓïÑÔÖÐÄ£°åµÄ¼¸ÖÖ (2025-12-26 15:49:47)