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

#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. C#中的 ref 传进出的到底是什么 解惑篇

    今天在浏览博文时,看到这篇文章:C#中的ref 传进出的到底是什么 ? 在传对象时使用ref的疑问 另附言: 本文写于早上,就在想发布的那瞬间,靠,公司断网了,原来修改的部分丢失了. 网一断就是一天了 ...

  2. Yii Framework处理网站前后台文件的方法

    此方法参考官方网站的cookbook,详细请看http://www.yiiframework.com/doc/cookbook/33/, 我在此基础上做了一些改动,人个感觉非常棒了,大家可以试一下! ...

  3. (转)linux下jvm 参数调优

    1.基本概念. JAVA_MEM_OPTS=" -server -Xmx2g -Xms2g -Xmn512m -XX:PermSize=128m -Xss256k -XX:+DisableE ...

  4. Mac下安装Twig模版引擎的方法

    本人收集了几种方法: 安装前: twig需要依赖PHP 5.2.7 才能运行. 1 通过composer安装(2种) 方法一: 首先确保你已经安装了composer,如果没有安装,可以参考https: ...

  5. android 数据库的创建

    主java package com.itheima.createdatabase; import android.app.Activity; import android.content.Contex ...

  6. 鼠标按键自定义软件-X-Mouse Button Control

    转载说明 本篇文章可能已经更新,最新文章请转:http://www.sollyu.com/mouse-button-x-mouse-button-custom-software-control/ 说明 ...

  7. 编译安装php Cannot find MySQL header files under /usr/include/mysql.

    编译php-5.5-6的mysql支持,出现Cannot find MySQL header files under /usr/include/mysql. Note that the MySQL c ...

  8. 译文:Javascript-function's return

    个人理解+google翻译.如有错误,请指正.原文来自MDN:return 概要 由function返回指定值. 版本信息 实现: JavaScript 1.0, NES 2.0(NES:游戏机在欧洲 ...

  9. mysql中的if条件语句用法

    · IF(expr1,expr2,expr3) 如果 expr1 是TRUE (expr1 <> 0 and expr1 <> NULL),则 IF()的返回值为expr2;  ...

  10. Spark Streaming揭秘 Day35 Spark core思考

    Spark Streaming揭秘 Day35 Spark core思考 Spark上的子框架,都是后来加上去的.都是在Spark core上完成的,所有框架一切的实现最终还是由Spark core来 ...