神犇帮看看,dp做的,蒟蒻感激不尽

评测结果
编译成功

测试数据 #0: Accepted, time = 0 ms, mem = 39648 KiB, score = 10
测试数据 #1: Accepted, time = 0 ms, mem = 39652 KiB, score = 10
测试数据 #2: Accepted, time = 0 ms, mem = 39648 KiB, score = 10
测试数据 #3: WrongAnswer, time = 0 ms, mem = 39648 KiB, score = 0
测试数据 #4: Accepted, time = 15 ms, mem = 39648 KiB, score = 10
测试数据 #5: Accepted, time = 0 ms, mem = 39652 KiB, score = 10
测试数据 #6: WrongAnswer, time = 0 ms, mem = 39648 KiB, score = 0
测试数据 #7: Accepted, time = 0 ms, mem = 39648 KiB, score = 10
测试数据 #8: Accepted, time = 0 ms, mem = 39648 KiB, score = 10
测试数据 #9: WrongAnswer, time = 0 ms, mem = 39652 KiB, score = 0
WrongAnswer, time = 15 ms, mem = 39652 KiB, score = 70
代码
#include <cstdio>
int dp[10000001],n,x,sum = 0;
int main() {
    scanf("%d%d",&n,&x);
    dp[x] = 1;
    for (int i = 1;i <= n;i++) {
        dp[i] = dp[i/10]+dp[i%10];
        sum += dp[i];
    }
    printf("%d",sum);
    return 0;
}

4 条评论

  • @ 2016-10-26 20:47:13
    // input code here
    
  • @ 2016-10-15 17:47:08

    谢谢指点~我和你一样的错法

  • @ 2016-09-04 10:07:05

    呵呵

  • @ 2016-08-30 00:48:01

    x=0的时候大概会出问题?

    • @ 2016-08-30 13:22:15

      已经发现错误了
      如果x=0,i=1 dp[1] = dp[0]+dp[1]
      但1没有0,这样就过了:
      c++
      #include <cstdio>
      int dp[10000001],n,x,sum = 0;
      int main() {
      scanf("%d%d",&n,&x);
      dp[x] = 1;
      for (int i = 1;i <= n;i++) {
      dp[i] = dp[i%10];
      if (i/10) dp[i] += dp[i/10];
      sum += dp[i];
      }
      printf("%d",sum);
      return 0;
      }

  • 1

信息

ID
1848
难度
5
分类
(无)
标签
递交数
16558
已通过
5790
通过率
35%
被复制
36
上传者