题解

123 条题解

  • 3
    @ 2017-05-08 09:02:15
    /*
    很明显这题就是一个乘法原理,我们求出每位上有可能的数字情况,
    然后所有情况数相乘即为最终答案
    我们可以考虑用Floyd的有向图的传递闭包
    因为如果a可以转成b b可以转成c
    那么a也可以转成c
    注意这里数据过大一定要用高精度乘法
    */
    #include <iostream>
    #include <cstdio>
    #include <algorithm>
    #include <cstring>
    using namespace std;
    
    const int MAXN=505;
    int ans[MAXN];
    bool map[12][12];
    int b[12];
    int k;
    string a;
    int x,y;
    int l=1;
    
    void work(int x)//高精度乘法
    {
        for(int i=0;i<l;i++)
            ans[i]*=x;
        for(int i=0;i<l;i++)
            if(ans[i]>=10)
            {
                ans[i+1]+=ans[i]/10;
                ans[i]%=10;
                l=max(l,i+2);
            }
    }
    
    int main()
    {
        cin>>a;
        cin>>k;
        for(int i=1;i<=k;i++)//先建图
        {
            cin>>x>>y;
            map[x][y]=1;
        }
        for(int i=0;i<=9;i++)//自己到自己为1
            map[i][i]=1;
        for(int k=0;k<=9;k++)//Floyd求出所有能转换的关系
            for(int i=0;i<=9;i++)
                for(int j=1;j<=9;j++)
                if(map[i][k]&&map[k][j])
                    map[i][j]=1;
        for(int i=0;i<=9;i++)//求出每个数字可以转换成多少个数字(注意包括自己)
        {
            int tot=0;
            for(int j=0;j<=9;j++)
                if(map[i][j])
                    tot++;
            b[i]=tot;
        }
        ans[0]=1;//高精度初始化1
        for(int i=0;i<a.length();i++)
            work(b[a[i]-'0']);//乘法原理
        for(int i=l-1;i>=0;i--)
            cout<<ans[i];
        return 0;
    }
         
    
  • 1
    @ 2019-08-02 17:42:34

    对不起,看到大整数立马Python起来:

    ss, n = map(str,input().split())
    n = int(n)
    test = [[0] * 10 for _ in range(10)]
    acc = []
    ans = 1
    
    for i in range(n):
        x, y = map(int, input().split())
        test[x][y] = 1
    for i in range(10):
        test[i][i] = 1
    for k in range(10):
        for i in range(10):
            for j in range(10):
                if test[i][k] == 1 & test[k][j] == 1:
                    test[i][j] = 1
    for i in range(10):
        acc.append(0)
        for j in range(10):
            if test[i][j] == 1:
                acc[i] += 1
    for i in range(len(ss)):
        ans *= acc[int(ss[i])]
    print(ans);
    
  • 1
    @ 2017-12-09 10:11:56
    /*
    其实可以不用高精度
    答案尾部有很多的0 把答案尾部的0的个数算出来 余下部分就可以long long
    */
    #include<bits/stdc++.h>
    using namespace std;
    
    int f[12]={0};
    int a[12][12]={0};
    string m;
    int n,i,j,k,x,y,t;
    long long p;
    
    int main(){
        cin >> m >> n;
        for (int i=1;i<=n;++i) {
            cin >> x >> y;
            a[x][y]=1;
        }
        for (int i=0;i<=9;++i) a[i][i]=1;
        for (int k=0;k<=9;++k)
            for (int i=0;i<=9;++i)
                for (int j=0;j<=9;++j)
                    if (a[i][k] && a[k][j]) a[i][j]=1;
        for (int i=0;i<=9;++i) 
            for (int j=0;j<=9;++j)
                f[i]+=a[i][j];
        p=1; t=0;
        for (int i=0;i<m.length();++i){
            p*=f[m[i]-'0'];
            while (p%10==0) {
                t++;
                p/=10;
            }
        }
        cout << p;
        for (int i=1;i<=t;++i) cout << 0;
    }
    
  • 0
    @ 2020-05-26 21:05:48
    #include <iostream>                 //[2002普及组-C]产生数
    #include <algorithm>
    #include <cstring>
    using namespace std;
    typedef long long ll;
    int num[10], cnt;
    int m[10][10];
    bool Vis[10];
    int number[1000], len;
    
    void dfs(int x)
    {
        for (int i = 0; i < 10; i++)
            if(m[x][i] && !Vis[i])
            {
                Vis[i] = true;
                cnt++;
                dfs(i);
            }
    }
    
    void mul(int number[], int k)
    {
        int add = 0;
        for (int i = 0; i < len; i++)
        {
            int t = number[i] * k + add;
            number[i] = t % 10;
            add = t / 10;
        }
        while (add)
        {
            number[len++] = add % 10;
            add /= 10;
        }
    }
    
    int main()
    {
        string n;
        int k, x, y;
        number[0] = 1, len = 1;
        cin >> n >> k;
    
        for (int i = 0; i < k; i++)
        {
            cin >> x >> y;
            m[x][y] = 1;
        }
    
        for (int i = 0; i < 10; i++)        //找出所有可达边
        {
            cnt = 0;
            memset(Vis, false, sizeof(Vis));
            Vis[i] = true;
            dfs(i);
            num[i] = cnt;
        }
    
        for (int i = 0; i < n.size(); i++)
            if(num[n[i] - '0'])
                mul(number, num[n[i] - '0'] + 1);
    
        for (int i = len - 1; i >= 0; i--)
            cout << number[i];
        cout << endl;
    
        system("pause");
        return 0;
    }
    
    
  • 0
    @ 2020-05-22 19:22:16
    #include<iostream>
    
    #include<string.h>
    #include<vector>
    #include<map>
    using namespace std;
    map<char,vector<char> > m;
    string s;
    int b[10];
    void dfs(char now){
        b[now-'0']=1;
        int len=m[now].size();
        for(int i=0;i<len;i++){
            if(!b[m[now][i]-'0']){
                dfs(m[now][i]);
            }
        }
    }
    int mul[100];
    int main(){
        int k;
        cin>>s>>k;
        for(int i=1;i<=k;i++){
            char x,y;
            cin>>x>>y;
            m[x].push_back(y);
        }
        int l=s.size();
        mul[0]=1;
        for(int i=0;i<l;i++){
            memset(b,0,sizeof(b));
            dfs(s[i]);
            int sum=0;
            for(int i=0;i<=9;i++){
                if(b[i]){
                    sum++;
                }
            }
            int x=0;
            for(int i=0;i<100;i++){
                mul[i]=mul[i]*sum+x;
                x=mul[i]/10;
                mul[i]%=10;
            }
        }
        int i=99;
        while(i>0&&!mul[i]){
            i--;
        }
        for(;i>=0;i--){
            cout<<mul[i];
        }
        return 0;
    }
    
  • 0
    @ 2017-08-28 17:20:35

    很水的题目,看清题意就好,直接把它转化为有向图,就是那个数字可以到那个数字,用folyd就好,因为时间就是O(100),folyd完后就直接乘法原理就可以了。

    
    Var
            ch:char;
            i,j,k,num,n,x,y,l,t:longint;
            a,b,c:array[0..1000]of longint;
            f:array[0..9,0..9]of boolean;
    Begin
            read(ch);
            while ch in ['0'..'9'] do
            begin
                    inc(a[ord(ch)-48]);
                    read(ch);
            end;
            readln(n);
            for i:=1 to n do
            begin
                    readln(x,y);
                    f[x,y]:=true;
            end;
            for i:=0 to 9 do
                    f[i,i]:=true;
    
            for k:=0 to 9 do
                    for i:=0 to 9 do
                            for j:=0 to 9 do
                                    f[i,j]:=f[i,j] or (f[i,k] and (f[k,j]));
    
            for i:=0 to 9 do
            begin
                    num:=0;
                    for j:=0 to 9 do
                            if f[i,j] then
                                    inc(num);
                    c[i]:=num;
            end;
            b[1]:=1; l:=1;
            for k:=0 to 9 do
                    for j:=1 to a[k] do
                    begin
                            for i:=1 to l do
                            begin
                                    b[i]:=b[i]*c[k]+t;
                                    t:=b[i] div 10;
                                    b[i]:=b[i] mod 10;
                            end;
                            if t>0 then
                            begin
                                    inc(l);
                                    b[l]:=t;
                                    t:=0;
                            end;
                    end;
    
            for i:=l downto 1 do
                    write(b[i]);
            writeln;
            readln;
    End.
    
    
    
    
  • 0
    @ 2016-09-05 21:27:44

    Floyd+高精度秒杀
    用Floyd求出每个数字可以变成多少种数字
    然后乘起来

    ```c++
    评测结果
    编译成功

    测试数据 #0: Accepted, time = 0 ms, mem = 580 KiB, score = 10
    测试数据 #1: Accepted, time = 0 ms, mem = 576 KiB, score = 10
    测试数据 #2: Accepted, time = 0 ms, mem = 580 KiB, score = 10
    测试数据 #3: Accepted, time = 0 ms, mem = 576 KiB, score = 10
    测试数据 #4: Accepted, time = 0 ms, mem = 576 KiB, score = 10
    Accepted, time = 0 ms, mem = 580 KiB, score = 50
    代码
    #include <iostream>
    #include <string>
    using namespace std;
    string str;
    int k,vis[10][10],f[10],num[101];
    inline void floyd() {
    for (int k = 0;k <= 9;k++)
    for (int i = 0;i <= 9;i++)
    for (int j = 0;j <= 9;j++) vis[i][j] = vis[i][j] || (vis[i][k] && vis[k][j]);
    }
    int main (){
    ios::sync_with_stdio(false);
    cin >> str >> k;
    while (k--) {
    int a,b;
    cin >> a >> b;
    vis[a][b] = true;
    }
    for (int i = 0;i <= 9;i++) vis[i][i] = true;
    floyd();
    for (int i = 0;i <= 9;i++)
    for (int j = 0;j <= 9;j++)
    if (vis[i][j]) f[i]++;
    int len = 2; num[1] = 1;
    for (int i = 0;i < (int)str.length();i++) {
    for (int j = 1;j <= 100;j++)
    num[j] *= f[str[i]-'0'];
    for (int j = 1;j <= 100;j++)
    if (num[j] >= 10) {
    num[j+1] += num[j]/10;
    num[j] %= 10;
    }
    while (num[len]) len++;
    }
    for (int i = len-1;i >= 1;i--) cout << num[i];
    return 0;
    }
    ```

  • 0
    @ 2016-07-29 10:21:59

    #include <cstdio>
    #include <cstring>
    #include <iostream>

    using namespace std;

    const int Maxn=31;

    char s[Maxn];
    int k,len,len1,tot[Maxn],ans[Maxn],dis[Maxn][Maxn];

    void mul(int c)
    {
    int x=0;
    for(int i=1;i<=len1;i++){
    ans[i]=ans[i]*c+x;
    x=ans[i]/10;
    ans[i]%=10;
    }
    while(x>0){ans[++len1]=x%10;x/=10;}
    }

    int main()
    {
    ans[1]=1;
    len1=1;
    for(int i=0;i<=9;i++)tot[i]=1;
    cin>>s+1;
    len=strlen(s+1);
    scanf("%d",&k);
    for(int i=1;i<=k;i++){
    int x,y;
    scanf("%d%d",&x,&y);
    if(!dis[x][y])tot[x]++;
    dis[x][y]=1;//建图
    }

    for(int k=0;k<=9;k++){//听起来很牛B的传递闭包(floyd实现)
    for(int i=0;i<=9;i++)
    if(dis[i][k]){
    for(int j=0;j<=9;j++)
    if(dis[i][k]&&dis[k][j]){
    if(i!=j&&!dis[i][j])tot[i]++;
    dis[i][j]=1;
    }
    }
    }

    for(int i=1;i<=len;i++)
    if(tot[s[i]-48]!=1){
    mul(tot[s[i]-48]);
    }

    for(int i=len1;i>=1;i--)printf("%d",ans[i]);
    }
    高精乘低精即可 加floyd传递闭包可秒杀

  • 0
    @ 2016-07-11 22:49:41

    这个题读题有点障碍,应该理解成,
    变换后的数字依旧可以变换
    例如:
    原式 123 规则 3-7 7-4
    就可以变成127再变成124
    基本思路
    Floyd(有向图)类似的方式算出0-9可以变成的数字的个数 高精度chg[] :
    floyd可以算出最短路 但这里只需要知道哪些点相连 只需map[i][j]>0 (初始为0)
    如果3点与7点相连 (有向) 就说明3可以变成7 执行chg[3]++
    自己也可以连向自己

    int count[x]代表x在原式出现的次数
    高精度 sum=1
    for(i=1~9) 高精度乘法 sum*=pow(chg[i],count[i])

    sum为所求

    附上代码

    #include <cstdio>
    #include <iostream>
    #include <cmath>
    #include <cstring>
    #define maxn 50 
    
    void multx(int a[],int b[],int c[]){
        memset(c,0,sizeof(int)*maxn);
        for(int i=1;i<=a[0];i++)
        for(int j=1;j<=b[0];j++){
            c[i+j-1]+=a[i]*b[j];
            c[i+j]+=c[i+j-1]/10000;
            c[i+j-1]%=10000;
        }
        int len=a[0]+b[0];
        while(c[len]==0&&len>1)
            len--;
        c[0]=len;
    }
    
    void output(int a[]){
        printf("%d",a[a[0]]);
        for(int i=a[0]-1;i>=1;i--)
            printf("%04d",a[i]);
    }
    
    int main(){
    //  freopen("in.txt","r",stdin);
        int count[10]={0},p,map[10][10]={0};
        int chg[10][maxn]={0};
        for(int i=0;i<=9;i++)
            chg[i][0]=1;
            
        int sum[maxn]={1,1};
        char a[100];
        std::cin>>a>>p;
        for(int i=1;i<=p;i++){
            int z,j;
            scanf("%d%d",&z,&j);
            map[z][j]=1;
        }
        for(int k=0;k<=9;k++)
        for(int i=0;i<=9;i++)
        for(int j=0;j<=9;j++)
            if(map[i][k]>0&&map[k][j]>0)
                map[i][j]=1;
                
        for(int i=0;i<strlen(a);i++)
            count[a[i]-'0']++;
            
        for(int i=0;i<=9;i++)
        for(int j=0;j<=9;j++)
            if(i==j||map[i][j]>0)
                chg[i][1]++;    
                    
        int temp[maxn],t[maxn],t2[maxn];        
        for(int i=0;i<=9;i++)
            if(count[i]>0){
                memcpy(temp,chg[i],sizeof(temp));
                memcpy(t2,temp,sizeof(temp));
                
                for(int x=1;x<=count[i]-1;x++){
                    multx(t2,temp,t);
                    memcpy(temp,t,sizeof(temp));
                }
                
                multx(sum,temp,t);
                memcpy(sum,t,sizeof(t));
            }
            
        output(sum);
        return 0;
    }
    
  • 0
    @ 2016-05-17 20:47:56

    var
    ch:char;
    s:string;
    f:array [0..10,0..10] of longint;
    a,b,c,d:array [0..1005] of longint;
    n,i,j,k,l,x,y:longint;
    begin
    read(ch);
    while (ch<>' ') do begin inc(a[ord(ch)-48]); read(ch); end;
    read(n); fillchar(f,sizeof(f),10);
    for i:=1 to n do begin read(x,y); f[x,y]:=0; end;
    for i:=0 to 9 do f[i,i]:=0;
    for k:=0 to 9 do
    for i:=0 to 9 do
    for j:=0 to 9 do
    if (f[i,j]>f[i,k]+f[k,j]) then f[i,j]:=f[i,k]+f[k,j];
    for i:=0 to 9 do
    for j:=0 to 9 do if f[i,j]=0 then inc(c[i]);
    d[1]:=1; l:=1;
    for i:=0 to 9 do
    for j:=1 to a[i] do
    begin
    for k:=1 to l do d[k]:=d[k]*c[i];
    for k:=1 to l do begin inc(d[k+1],d[k] div 10); d[k]:=d[k] mod 10; end;
    if (d[l+1]<>0) then inc(l);
    end;
    for i:=l downto 1 do write(d[i]);
    end.

  • 0
    @ 2016-01-20 20:26:11

    这个n<10的30次方是什么鬼?O(N)都过不了啊

  • 0
    @ 2015-11-04 17:46:12

    条件是什么意思?急!!!!

  • 0
    @ 2015-10-06 22:21:46

    记录信息
    评测状态 Accepted
    题目 P1129 产生数
    递交时间 2015-10-06 22:19:31
    代码语言 C++
    评测机 VijosEx
    消耗时间 2 ms
    消耗内存 532 KiB
    评测时间 2015-10-06 22:19:32
    评测结果
    编译成功

    foo.cpp: In function 'int main()':
    foo.cpp:40:10: warning: statement has no effect [-Wunused-value]
    for(cnt;cnt<=maxn||in;cnt++)
    ^
    测试数据 #0: Accepted, time = 0 ms, mem = 524 KiB, score = 10
    测试数据 #1: Accepted, time = 0 ms, mem = 528 KiB, score = 10
    测试数据 #2: Accepted, time = 0 ms, mem = 528 KiB, score = 10
    测试数据 #3: Accepted, time = 0 ms, mem = 532 KiB, score = 10
    测试数据 #4: Accepted, time = 2 ms, mem = 524 KiB, score = 10
    Accepted, time = 2 ms, mem = 532 KiB, score = 50
    代码
    #include <iostream>
    #include <cstdio>
    #include <string.h>
    using namespace std;
    int num[10][10];
    int nk[10];
    int ans[123];
    char s[123];
    int main()
    {
    int kn;
    scanf("%s",s+1);
    scanf("%d",&kn);

    s[0]='1';
    memset(num,0,sizeof(num));
    int len=strlen(s)-1;
    int a,b;
    for(int i=1;i<=kn;i++)
    {
    scanf("%d%d",&a,&b);
    num[a][b]=1;
    }
    for(int i=0;i<=9;i++)num[i][i]=1;
    //floyd算法
    for(int k=0;k<=9;k++)
    for(int i=0;i<=9;i++)
    for(int j=0;j<=9;j++)
    if(num[i][k]==1&&num[k][j]==1)
    num[i][j]=1;
    for(int i=0;i<=9;i++)
    for(int j=0;j<=9;j++)
    nk[i]+=num[i][j];
    //高精度
    int maxn=1;
    ans[1]=1;
    for(int pos=1;pos<=len;pos++)
    {
    int nc=nk[s[pos]-'0'];
    int in=0,cnt=1;
    for(cnt;cnt<=maxn||in;cnt++)
    {

    ans[cnt]=nc*ans[cnt]+in;
    in=ans[cnt]/10;
    ans[cnt]%=10;
    }
    if(cnt-1>maxn)maxn=cnt-1;
    }

    for(int i=maxn;i>=1;i--)printf("%d",ans[i]);

    }

  • 0
    @ 2015-06-01 08:44:29

    这题目真是困扰了我好久......自己去网上了解“传递闭包”这个概念然后做了很多遍,都是60分,现在终于AC
    关键就是传递闭包时i,j,k的顺序,应该把中间量j放在循环最外层,这样的传递才不会因输入顺序不同造成遗漏
    开始还以为是精度问题,所以最后写了高精度

    #include<stdio.h>
    #include<string.h>
    int main( )
    {
    int gjd[100]={0};
    char g[31];
    int a,i,k[11]={0},x,y,n,fy[11][11],j,l,pot=1,zc,xx;
    scanf("%s",&g);
    scanf("%d",&a);
    n=strlen(g);

    for(i=0;i<=9;i++)
    for(j=0;j<=9;j++)
    fy[i][j]=0;

    for(i=1;i<=a;i++)
    {
    scanf("%d %d",&x,&y);
    if(y!=0) fy[x][y]=1;
    }

    for(i=0;i<=9;i++)
    fy[i][i]=1;

    for(j=0;j<=9;j++)
    for(i=0;i<=9;i++)
    for(l=0;l<=9;l++)

    if(fy[i][j]==fy[j][l] && fy[i][j]==1) fy[i][l]=1;

    for(i=0;i<=9;i++)
    for(j=0;j<=9;j++)
    if(fy[i][j]==1) k[i]=k[i]+1;

    gjd[1]=1;

    for(i=0;i<=n-1;i++)
    {
    for(j=1;j<=pot;j++)
    gjd[j]=gjd[j]*(k[g[i]-48]);
    zc=pot;
    for(j=1;j<=zc;j++)
    {
    if(gjd[j]>=10) {xx=gjd[j]/10;
    gjd[j]=gjd[j]-10*xx;
    gjd[j+1]=gjd[j+1]+xx;
    if(j==zc) pot++;}
    }

    }

    for(i=pot;i>=1;i--)

    printf("%d",gjd[i]);

    return 0;
    }

  • 0
    @ 2014-09-24 23:19:48

    program Project1;

    var
    v, u, x, y: array[0..9] of longint;
    a: array[0..9, 0..9] of longint;
    b: array[1..1000] of longint;
    sum: array[1..10000] of longint;
    i, t1, k, t, Result, j, h: longint;
    c: char;
    w: array[0..9, 0..9] of boolean;

    procedure cz;
    var

    i, j, k1: longint;
    begin

    for i := 0 to 9 do
    w[i, i] := True;
    for k1 := 0 to 9 do
    for i := 0 to 9 do
    for j := 0 to 9 do

    begin
    if (k1 = i) or (i = j) or (i = k1) then
    h := 1
    else
    if (w[i, j] = False) and (w[i, k1] = True) and (w[k1, j] = True) and
    (a[i, j] < a[i, k1] + a[k1, j]) then
    begin
    w[i, j] := True;
    a[i, j] := a[i, k1] + a[k1, j];
    end;
    end;
    for i := 0 to 9 do
    for j := 0 to 9 do
    if w[i, j] then
    Inc(v[i]);

    end;

    procedure fj;
    var
    c: array[1..1000] of longint;
    x: longint;
    begin
    fillchar(b, sizeof(b), 0);
    fillchar(c, sizeof(c), 0);
    x := v[i];
    t := 0;
    while x <> 0 do
    begin
    Inc(t);
    c[t] := x mod 10;
    x := x div 10;
    end;
    for j := 1 to t do
    b[j] := c[j];
    end;

    procedure gj;
    var
    j, k: longint;
    su: array[1..10000] of longint;
    begin
    fillchar(su, sizeof(su), 0);
    for j := 1 to t1 do
    su[j] := sum[j];
    fillchar(sum, sizeof(sum), 0);
    for j := 1 to t1 do
    for k := 1 to t do
    begin
    sum[j + k - 1] := su[j] * b[k] + sum[j + k - 1];
    if sum[j + k - 1] > 9 then
    begin
    sum[j + k] := sum[j + k - 1] div 10;
    sum[j + k - 1] := sum[j + k - 1] mod 10;
    if t1 < j + k then
    t1 := j + k;
    end;
    if t1 < j + k - 1 then
    t1 := j + k - 1;
    end;
    end;

    begin
    Read(c);
    fillchar(w, sizeof(w), False);
    while c <> ' ' do
    begin
    val(c, i, Result);
    Inc(u[i]);
    Read(c);
    end;
    Read(k);
    readln;
    for i := 1 to k do
    begin
    readln(x[i], y[i]);
    a[x[i], y[i]] := 1;
    w[x[i], y[i]] := True;
    end;
    cz;
    sum[1] := 1;
    t1 := 1;
    h := 0;
    for i := 0 to 9 do
    begin
    if (u[i] <> 0) and (v[i] <> 0) then
    begin
    fj;
    for j := 1 to u[i] do
    gj;
    end;
    end;
    for i := t1 downto 1 do
    Write(sum[i]);
    end.

  • 0
    @ 2013-11-24 20:11:03

    对于每一位,统计出他能变换成哪些数字(包括他本身),之后每一位都有ai种选择,所以根据乘法原理,将每一位的选择数相乘,但是结果得高精。至于统计选择的数量,用FLOYD即可。
    下面贴代码,我只是个蒟蒻,写得麻烦的话求不喷。
    #include<iostream>
    #include<cstdio>
    using namespace std;
    int kps[30]={0};
    void p(int x)
    {
    for(int i=1;i<=kps[0];i++)kps[i]=kps[i]*x;for(int i=1;i<=kps[0];i++){kps[i+1]=kps[i+1]+(kps[i]/10);kps[i]=kps[i]%10;}
    for(kps[0]++;kps[kps[0]]!=0;kps[0]++){kps[kps[0]+1]=kps[kps[0]+1]+(kps[kps[0]]/10);kps[kps[0]]=kps[kps[0]]%10;}kps[0]--;
    }
    int main()
    {
    bool map[11][11]={false};int n,k;
    char calc[100];int ans=0;
    for(scanf("%c",&calc[0]);calc[ans]!=' ';ans++){scanf("%c",&calc[ans+1]);}
    scanf("%d",&k);
    for(int i=1;i<=k;i++){int o,l;scanf("%d%d",&o,&l);map[o][l]=true;}
    for(int i=0;i<=9;i++)map[i][i]=true;for(int k=0;k<=9;k++)for(int i=0;i<=9;i++)for(int j=0;j<=9;j++)if(map[i][k]==true)if(map[k][j]==true)map[i][j]=true;
    int f[10]={0};for(int i=0;i<=9;i++)for(int j=0;j<=9;j++)if(map[i][j]==true)f[i]++;kps[0]=1;kps[1]=1;for(int i=0;i<=ans-1;i++){p(f[(calc[i]-'0')]);n=n/10;}
    for(int i=kps[0];i>0;i--)printf("%d",kps[i]);return 0;
    }

    • @ 2014-08-18 02:34:04

      orz skydec!!!

    • @ 2014-08-18 02:36:10

      无限ORZ未来Au爷skydec!!!

  • 0
    @ 2013-11-05 21:13:26

    var
    s:string;
    j,i,k,p,x,y,n:longint;
    f:array[0..9,0..9] of boolean;
    ans:real;
    begin
    readln(s);
    p:=pos(' ',s);
    val(copy(s,p+1,100),n);
    delete(s,p,100);
    for i:=1 to n do
    begin
    readln(x,y);
    f[x,y]:=true;
    end;
    for k:=0 to 9 do
    for i:=0 to 9 do
    for j:=0 to 9 do
    if (i<>j) and (i<>k) and (k<>j) then f[i,j]:=f[i,j] or f[i,k] and f[k,j];
    ans:=1;
    for i:=1 to length(s) do
    begin
    j:=ord(s[i])-48;
    p:=1;
    for k:=0 to 9 do
    if f[j,k] then inc(p);
    ans:=ans*p;
    end;
    writeln(ans:0:0);
    end.
    膜拜LGS大牛。
    本来要老老实实高精。
    他的建议太强了!
    只是担心比赛时万一出了精度问题。。。。。

  • 0
    @ 2013-10-03 11:30:27

    其实不用写高精的,把ANS开成real,然后取整就AC了,一遍秒杀!;FOLYED;
    L.G.S-庆祝国庆节

  • 0
    @ 2013-07-20 17:41:30

    why? Who can help me?
    VijosEx via JudgeDaemon2/13.7.4.0 via libjudge

    编译成功

    测试数据 #0: WrongAnswer, time = 15 ms, mem = 732 KiB, score = 0

    测试数据 #1: WrongAnswer, time = 15 ms, mem = 728 KiB, score = 0

    测试数据 #2: WrongAnswer, time = 15 ms, mem = 732 KiB, score = 0

    测试数据 #3: WrongAnswer, time = 15 ms, mem = 732 KiB, score = 0

    测试数据 #4: WrongAnswer, time = 0 ms, mem = 728 KiB, score = 0

    WrongAnswer, time = 60 ms, mem = 732 KiB, score = 0

    var
    i,j,k,e,y,x,p,f,n:integer;
    ch:char;
    a,s,c:array[1..50] of integer;
    b:array[1..15] of integer;
    procedure ready;
    begin
    n:=0;
    y:=0;
    read(ch);
    while ch<>' ' do
    begin
    inc(n);
    a[n]:=ord(ch)-ord('0');
    read(ch);
    end;
    readln(k);
    for x:=1 to k do readln(b[x]);
    for j:=1 to n do
    c[j]:=1;
    for e:=1 to n do
    for j:=1 to k do
    if b[j]=a[e] then inc(c[e]);
    end;
    procedure gao;
    var i,t,max,ma:integer;
    begin
    for i:=1 to 50 do s[i]:=0;
    s[1]:=1;
    i:=1; max:=1;
    while i<=n do
    begin
    j:=1;
    while j<=max do
    begin
    ma:=max;
    s[j]:=s[j]*c[i];
    p:=j;
    while s[p]>=10 do
    begin
    t:=s[p];
    s[p]:=t mod 10;
    s[p+1]:=s[p+1]+(t div 10);
    inc(p);
    end;
    if p>ma then ma:=p;
    inc(j);
    end;
    if ma>max then max:=ma;
    inc(i);
    end;
    end;
    procedure print;
    begin
    for f:=1 to p do write(s[f]);
    end;
    begin
    ready;
    gao;
    print;
    end.

  • 0
    @ 2012-08-24 08:32:33

    算法:DFS + 高精度乘法 + 乘法原理

信息

ID
1129
难度
6
分类
高精度 点击显示
标签
递交数
3872
已通过
1107
通过率
29%
被复制
26
上传者