Pascal字符串秒过

var
  n,i,j,ans,x:longint;
  s:string;
begin
  readln(n,x);
  ans:=0;
  for i:=1 to n do
    begin
      str(i,s);
      for j:=1 to length(s) do
        if s[j]=chr(x+48)
          then
            inc(ans);
    end;
  writeln(ans);
end.

1 条评论

  • @ 2016-11-12 15:42:07

    c++ dp秒过
    ```
    评测结果
    编译成功

    测试数据 #0: Accepted, time = 0 ms, mem = 39652 KiB, score = 10
    测试数据 #1: Accepted, time = 0 ms, mem = 39648 KiB, score = 10
    测试数据 #2: Accepted, time = 0 ms, mem = 39648 KiB, score = 10
    测试数据 #3: Accepted, time = 0 ms, mem = 39648 KiB, score = 10
    测试数据 #4: Accepted, time = 0 ms, mem = 39648 KiB, score = 10
    测试数据 #5: Accepted, time = 0 ms, mem = 39648 KiB, score = 10
    测试数据 #6: Accepted, time = 0 ms, mem = 39648 KiB, score = 10
    测试数据 #7: Accepted, time = 0 ms, mem = 39648 KiB, score = 10
    测试数据 #8: Accepted, time = 0 ms, mem = 39648 KiB, score = 10
    测试数据 #9: Accepted, time = 0 ms, mem = 39648 KiB, score = 10
    Accepted, time = 0 ms, mem = 39652 KiB, score = 100
    代码
    #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
分类
(无)
标签
递交数
16552
已通过
5786
通过率
35%
被复制
36
上传者