zoukankan      html  css  js  c++  java
  • 洛谷P1013 进制位 数论

    洛谷P1013 进制位 数论

    首先我们可以发现一个有趣的性质,就是1一定要有,因为有进位就一定会有一嘛,
    额,其实我也不会证,题解上说一定是连续的几个数,且一定会包含一
    根据这个条件,我们可以发现如果只算那些只由一个字母构成的,我们可以发现,一个字母如果
    出现n次,那么其表示的数就是 n-1
    那么如何判断不可行呢,如果有一个字母出现次数为 0 则表示其不可行

    #include <cstdio>
    #include <cmath>
    #include <cstdlib>
    #include <cstring>
    #include <algorithm>
    #include <string>
    #include <iomanip>
    #include <iostream>
    using namespace std ;
    
    int n,l ;
    char s[10],s1[10] ;
    char ss[10][10] ;
    int a[200] ;
    
    
    int main() 
    {
        cin>>n;
        cin>>s ;
        for(int i=2;i<=n;i++) cin>>ss[ i ] ;
        for(int i=2;i<=n;i++) 
        {
            cin>>s; 
            for(int j=2;j<=n;j++) 
            {
                cin>>s ;
                l = strlen(s) ;
                if(l>1) continue ;
                a[ s[0] ]++ ;      
            } 
        }
        for(int i=2;i<=n;i++) 
            if(a[ ss[i][0] ]-1==-1) 
            {
                printf("ERROR!
    ") ; 
                return 0 ;
            }
        for(int i=2;i<=n;i++) 
            printf("%s",ss[i]),printf("=%d ",a[ ss[i][0] ]-1) ;
            
        printf("
    %d
    ",n-1) ;
         
        return 0 ; 
    }
  • 相关阅读:
    View转化为bitmap
    Bitmap 与Drawable相互转换
    android studio 连接不到真机
    解决Android sync无法同步问题
    Stetho管理手机
    android sugar no such table
    android 建数据库的正确写法
    android JSON 数据解析
    android notification 理解
    android aidl 简单使用
  • 原文地址:https://www.cnblogs.com/third2333/p/6813053.html
Copyright © 2011-2022 走看看