http://codeforces.com/contest/376/problem/C

题意:给你一个大数最多含有10^6个数字,这里面必须含有1,6,8,9,然后重新排列找出一个能被6整除的数。

思路:1,6,8,9排列组成的四位数取余7为0,1,2,3,4,5,6;

所以可以这样排列前面的数是其它的数+1,6,8,9排列组成的数+多个0;

 #include <cstdio>
#include <cstring>
#include <algorithm>
#define maxn 1000010
using namespace std; char str[maxn];
int cnt[];
int num[] = {,,,,,,}; int main()
{
for(int i=; i<; i++)
{
printf("%d\n",num[i]%);
}
while(scanf("%s",str)!=EOF)
{
memset(cnt,,sizeof(cnt));
int k=strlen(str);
for(int i=; i<k; i++)
{
cnt[str[i]-'']++;
}
cnt[]--;
cnt[]--;
cnt[]--;
cnt[]--;
int c=;
for(int i=; i<=; i++)
{
for(int j=; j<=cnt[i]; j++)
{
printf("%d",i);
c=(c*+i)%;
}
}
printf("%d",num[c]);
for(int i=; i<=cnt[]; i++)
{
printf("");
}
printf("\n");
}
return ;
}

cf C. Divisible by Seven的更多相关文章

  1. ORA-00494: enqueue [CF] held for too long (more than 900 seconds) by 'inst 1, osid 5166'

    凌晨收到同事电话,反馈应用程序访问Oracle数据库时报错,当时现场现象确认: 1. 应用程序访问不了数据库,使用SQL Developer测试发现访问不了数据库.报ORA-12570 TNS:pac ...

  2. Codeforces CF#628 Education 8 F. Bear and Fair Set

    F. Bear and Fair Set time limit per test 2 seconds memory limit per test 256 megabytes input standar ...

  3. Codeforces CF#628 Education 8 B. New Skateboard

    B. New Skateboard time limit per test 1 second memory limit per test 256 megabytes input standard in ...

  4. cf之路,1,Codeforces Round #345 (Div. 2)

     cf之路,1,Codeforces Round #345 (Div. 2) ps:昨天第一次参加cf比赛,比赛之前为了熟悉下cf比赛题目的难度.所以做了round#345连试试水的深浅.....   ...

  5. cf Round 613

    A.Peter and Snow Blower(计算几何) 给定一个点和一个多边形,求出这个多边形绕这个点旋转一圈后形成的面积.保证这个点不在多边形内. 画个图能明白 这个图形是一个圆环,那么就是这个 ...

  6. ARC下OC对象和CF对象之间的桥接(bridge)

    在开发iOS应用程序时我们有时会用到Core Foundation对象简称CF,例如Core Graphics.Core Text,并且我们可能需要将CF对象和OC对象进行互相转化,我们知道,ARC环 ...

  7. [Recommendation System] 推荐系统之协同过滤(CF)算法详解和实现

    1 集体智慧和协同过滤 1.1 什么是集体智慧(社会计算)? 集体智慧 (Collective Intelligence) 并不是 Web2.0 时代特有的,只是在 Web2.0 时代,大家在 Web ...

  8. CF memsql Start[c]UP 2.0 A

    CF memsql Start[c]UP 2.0 A A. Golden System time limit per test 1 second memory limit per test 256 m ...

  9. CF memsql Start[c]UP 2.0 B

    CF memsql Start[c]UP 2.0 B B. Distributed Join time limit per test 1 second memory limit per test 25 ...

随机推荐

  1. Mac内建Apache开机启动

    取消: sudo launchctl unload -w /System/Library/LaunchDaemons/org.apache.httpd.plist 添加: sudo launchctl ...

  2. 项目经历——EasyUI的检索和更新操作

    什么事都耐不住“磨”?! 比如一个让人很头疼的问题,对于项目中所用到的EasyUI框架就是一个很明显的感受.项目使用的EasyUI框架,自身封装好的样式使得开发者不用考虑具体的div和css样式了,但 ...

  3. OneToMany与ManyToOne的属性

    供自己查阅,嫌低级的勿喷! 1.OneToMany的属性 ①targetEntity 定义关系类的类型,默认是该成员属性对应的类类型,所以通常不需要提供定义. ②mappedBy 定义类之间的双向关系 ...

  4. MySQL Replication, 主从和双主配置

    MySQL Replication, 主从和双主配置 MySQL的Replication是一种多个MySQL的数据库做主从同步的方案,特点是异步,广泛用在各种对MySQL有更高性能,更高可靠性要求的场 ...

  5. [Angular 2] Using Pipes to Filter Data

    Pipes allow you to change data inside of templates without having to worry about changing it in the ...

  6. MySQL如何有效地创建基于 INNODB 引擎的表

    2016-05-27 赵伟 数据库开发者 有用户问我们为什么下面这个建表语句会执行失败,报错是 "Row size too large ...."下面我就以这个例子出发讲一讲使用m ...

  7. [转] FDA批准首个莫米松植入式给药系统用于治疗慢性鼻窦炎

    from: http://www.qqyy.com/jibing/erbihouke/111020/3fd2f.html http://www.chemdrug.com/news/231/5/2494 ...

  8. Day1 - Python基础1 介绍、基本语法、流程控制

    Python之路,Day1 - Python基础1   本节内容 Python介绍 发展史 Python 2 or 3? 安装 Hello World程序 变量 用户输入 模块初识 .pyc是个什么鬼 ...

  9. tomcat发布去掉项目的名称

    1.找到tomcat的文件夹,打开conf目录的server.xml,我的是Linux系统所以用vi server.xml,总之打开就行 2.找到如下语句 加入下面箭头的路径,docBase为项目所在 ...

  10. 没有懂的leetcode

    Given a collection of candidate numbers (C) and a target number (T), find all unique combinations in ...