规律还是比较好找的  大数除法

#include <cstdio>
#include <cstring>
int len,a[1000],q;
int cc[] = {0,1,2,5,9,8,6};
bool check()
{
    for(; q < len; q++)
        if(a[q])
        return true;
    return false;
}
int mod(int *s)
{
    int t = 0;
    for(int i = q; i < len; i++)
    {
        t *= 10;
        t += s[i];
        s[i] = t/7;
        t %= 7;
    }
    return t;
}
int main()
{
    int t;
    scanf("%d",&t);
    while(t--)
    {
        q = 0;
        char s[500];
        scanf("%s",s);
        len = strlen(s);
        for(int i = 0; i < len; i++)
            a[i] = s[i]-'0';
        while(check())
            printf("%d", cc[mod(a)]);
        puts("");
    }
    return 0;
}

spoj 362的更多相关文章

  1. SPOJ 362 Ignore the Garbage 转7进制+简单大数除法

    显然正着倒着看仍然是数字的只有7个数:0,1,2,5,6,8,9 所以就是用这7个数组合成不同的数. 将n转换成7进制,对应位输出即可. #include <cstdio> #includ ...

  2. BZOJ 2588: Spoj 10628. Count on a tree [树上主席树]

    2588: Spoj 10628. Count on a tree Time Limit: 12 Sec  Memory Limit: 128 MBSubmit: 5217  Solved: 1233 ...

  3. SPOJ DQUERY D-query(主席树)

    题目 Source http://www.spoj.com/problems/DQUERY/en/ Description Given a sequence of n numbers a1, a2, ...

  4. SPOJ GSS3 Can you answer these queries III[线段树]

    SPOJ - GSS3 Can you answer these queries III Description You are given a sequence A of N (N <= 50 ...

  5. 【填坑向】spoj COT/bzoj2588 Count on a tree

    这题是学主席树的时候就想写的,,, 但是当时没写(懒) 现在来填坑 = =日常调半天lca(考虑以后背板) 主席树还是蛮好写的,但是代码出现重复,不太好,导致调试的时候心里没底(虽然事实证明主席树部分 ...

  6. SPOJ bsubstr

    题目大意:给你一个长度为n的字符串,求出所有不同长度的字符串出现的最大次数. n<=250000 如:abaaa 输出: 4 2 1 1 1 spoj上的时限卡的太严,必须使用O(N)的算法那才 ...

  7. 解决zookeeper报错[NIOServerCxn.Factory:0.0.0.0/0.0.0.0:2181:NIOServerCnxn@362] - Exception causing close

    zookeeper.out报错: 2016-12-10 18:05:46,958 [myid:3] - WARN  [NIOServerCxn.Factory:0.0.0.0/0.0.0.0:2181 ...

  8. 【SPOJ 7258】Lexicographical Substring Search

    http://www.spoj.com/problems/SUBLEX/ 好难啊. 建出后缀自动机,然后在后缀自动机的每个状态上记录通过这个状态能走到的不同子串的数量.该状态能走到的所有状态的f值的和 ...

  9. 【SPOJ 1812】Longest Common Substring II

    http://www.spoj.com/problems/LCS2/ 这道题想了好久. 做法是对第一个串建后缀自动机,然后用后面的串去匹配它,并在走过的状态上记录走到这个状态时的最长距离.每匹配完一个 ...

随机推荐

  1. HDOJ2028Lowest Common Multiple Plus

    Lowest Common Multiple Plus Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 65536/32768 K (J ...

  2. jQuery中ajax应用

    一:Ajax介绍 1.ajax的定义:客服端js所发起的http请求的代号,无刷新的数据更新. 2.ajax原理: 运用XHTML+CSS来表达信息,运用javascript操作DOM(Documen ...

  3. Android类库打包方法探究

    原文地址: http://www.cnblogs.com/wangchuanju/archive/2012/04/05/android_lib_jar.html 开发Android应用的时候,对于可用 ...

  4. 第一个MapReduce程序

    计算文件中每个单词的频数 wordcount 程序调用 wordmap 和 wordreduce 程序. import org.apache.hadoop.conf.Configuration; im ...

  5. 添加线标注ILineElement

    private void AddLineElement(IPolyline polyline) { try { IPolyline pPolyline = polyline; IRgbColor pL ...

  6. 暑假集训(5)第一弹——— Super Jumping! Jumping! Jumping!(hdu1087)

    题意概括:在上次与娑殚的三次博弈中,你们都取得了胜利.便向娑殚提出要求,借助他的力量,传送到一个安全的地方. 你们的愿望达成了,不过,你和小A似乎失散了. 街上人来人往的特别热闹,每一个人的脸上都洋溢 ...

  7. 函数 sort,unique,stable_sort,count_if,谓词

    bool isShorter(const string &s1,const string &s2) { return s1.size() < s2.size(); } bool ...

  8. 菜鸟级asp.net 与ms sql server数据库打交道的简单总结

    using System.Data.SqlClient;using System.Data; 上面是必须的 下面说的都是用存储过程 首先是webconfig里面的连接字符串: <connecti ...

  9. Docker容器里时间与宿主机不同步

    docker容器里时间设置: 第一种: Dockerfile文件中添加一行:RUN cp /usr/share/zoneinfo/Asia/Shanghai /etc/localtime或者 第二种: ...

  10. c# Aes加解密和对象序列化

    aes加解密 public class AesCryptto { private string key = "hjyf57468jhmuist"; private string i ...