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. 用于A*的 二叉堆 AS3实现

    package com.copper.isometric.pathing {     import flash.sampler.startSampling;           /**      * ...

  2. C#快速剔除字符串中不合法的文件名或者文件路径字符

    C#快速剔除字符串中不合法的文件名 string strFileName= "文件名称";  StringBuilder rBuilder = new StringBuilder( ...

  3. 统计学习导论:基于R应用——第五章习题

    第五章习题 1. 我们主要用到下面三个公式: 根据上述公式,我们将式子化简为 对求导即可得到得到公式5-6. 2. (a) 1 - 1/n (b) 自助法是有有放回的,所以第二个的概率还是1 - 1/ ...

  4. nginx的upstream目前支持5种方式的分配

    Nginx   nginx的upstream目前支持5种方式的分配 FROM: 转载 1 轮询(默认) 每个请求按时间顺序逐一分配到不同的后端服务器, 如果后端服务器down掉, 能自动剔除. 2 w ...

  5. Queueing in the Linux Network Stack !!!!!!!!!!!!!!!

    https://www.coverfire.com/articles/queueing-in-the-linux-network-stack/ Queueing in the Linux Networ ...

  6. sdaf

  7. WebView使用详解(一)——Native与JS相互调用(附JadX反编译)

    念念不忘,必有回响,永远坚持你所坚持的! 一直在用WebView,还没有系统的总结过它的用法,下面就系统的总结下,分享给大家 一.基本用法 1.加载在线URL void loadUrl(String ...

  8. yii2 控制器里 action 大小写组合造成的路由问题

    yii1中, 若存在如下控制器 class BindController extends CController { public function actionGetMobilePhone () { ...

  9. Python中利用函数装饰器实现备忘功能

    Python中利用函数装饰器实现备忘功能 这篇文章主要介绍了Python中利用函数装饰器实现备忘功能,同时还降到了利用装饰器来检查函数的递归.确保参数传递的正确,需要的朋友可以参考下   " ...

  10. C#解leetcode 189. Rotate Array

    Rotate an array of n elements to the right by k steps. For example, with n = 7 and k = 3, the array  ...