给你长度为 10^5~10^6长度,由数字组成的串 其中有4位不见了 补全该串 使得在该串能整除 77的同时 尽可能大
// 先计算出每个 n*10^m 模 77 的循环节 n=0,1,2..,9
// 然求出串的每位 mod 77 累加 抹黑的4为另外处理 #include <iostream>
#include <algorithm>
#include <queue>
#include <vector>
#include <math.h>
#include <stdio.h>
#include <string.h>
using namespace std;
#define maxm 100010
#define maxn 1000110
int rc[][];
int num[];
void calculate(int n){
int vi[]={};
int m=n;
int ct=;
rc[m][ct++]=m;
vi[n]=true;
while(){
n=n*;
n=n%;
if(vi[n]) break;
vi[n]=true;
rc[m][ct++]=n;
// printf("%d\n",n);
}
num[m]=ct;
}
char str[maxn];
int main()
{
int i,j,k,l;
int d[]={,,,,,,,,,,};
int a[];
for(i=;i<=;i++)
calculate(i);
num[]=;
// for(i=1;i<=9;printf("\n"),i++)
// for(j=0;j<num[i];j++)
// printf("%d ",rc[i][j]);
int tp;
// printf("%d\n",11167%77);
while(scanf("%s",str)!=EOF){
int len=strlen(str);
tp=j=;
for(i=;i<len;i++){
if(str[len-i-]!='x'){
k=str[len-i-]-'';
tp+=rc[k][i%num[k]];
}else{
a[++j]=i;
// printf("%d ",i);
}
}
// printf("%d\n",tp);
int lin;
int flag=;
for(i=;i<=;i++)
{
for(j=;j<=;j++)
{
for(k=;k<=;k++){
for(l=;l<=;l++){
lin=tp+rc[d[l]][a[]%num[d[l]]];
lin=lin+rc[d[k]][a[]%num[d[k]]];
lin=lin+rc[d[j]][a[]%num[d[j]]];
lin=lin+rc[d[i]][a[]%num[d[i]]];
if(lin%==) {flag=;break;}
}
if(!flag) break;
}
if(!flag) break;
}
if(!flag) break;
}
str[len-a[]-]=''+d[l];
str[len-a[]-]=''+d[k];
str[len-a[]-]=''+d[j];
str[len-a[]-]=''+d[i];
printf("%s\n",str); }
return ;
}

fzu 1675 The Seventy-seven Problem的更多相关文章

  1. FZU 2224 An exciting GCD problem(GCD种类预处理+树状数组维护)同hdu5869

    题目链接:http://acm.fzu.edu.cn/problem.php?pid=2224 同hdu5869 //#pragma comment(linker, "/STACK:1024 ...

  2. FZU 2240 Daxia & Suneast's problem

    博弈,$SG$函数,规律,线段树. 这个问题套路很明显,先找求出$SG$函数值是多少,然后异或起来,如果是$0$就后手赢,否则先手赢.修改操作和区间查询的话可以用线段树维护一下区间异或和. 数据那么大 ...

  3. FZU - 2038 -E - Another Postman Problem (思维+递归+回溯)

    Chinese Postman Problem is a very famous hard problem in graph theory. The problem is to find a shor ...

  4. FZU 2238 Daxia & Wzc's problem

    公式. $a×C_{m + i - 1}^m + d×C_{m + i - 1}^{m + 1}$. 推导过程可以看http://blog.csdn.net/queuelovestack/articl ...

  5. HITtrainning20140417题解

    题目列表:     ID Origin Title 10 / 15 Problem A FZU 2152 文件系统   0 / 16 Problem B FZU 2153 A simple geome ...

  6. (01背包 当容量特别大的时候) Knapsack problem (fzu 2214)

    http://acm.fzu.edu.cn/problem.php?pid=2214   Problem Description Given a set of n items, each with a ...

  7. fzu Problem 2148 Moon Game(几何 凸四多边形 叉积)

    题目:http://acm.fzu.edu.cn/problem.php?pid=2148 题意:给出n个点,判断可以组成多少个凸四边形. 思路: 因为n很小,所以直接暴力,判断是否为凸四边形的方法是 ...

  8. fzu Problem 2140 Forever 0.5(推理构造)

    题目:http://acm.fzu.edu.cn/problem.php?pid=2140 题意: 题目大意:给出n,要求找出n个点,满足: 1)任意两点间的距离不超过1: 2)每个点与(0,0)点的 ...

  9. fzu 2037 Maximum Value Problem

    http://acm.fzu.edu.cn/problem.php?pid=2037 思路:找规律,找出递推公式f[n]=f[n-1]*n+(n-1)!,另一个的结果也是一个递推,s[n]=s[n-1 ...

随机推荐

  1. js冒泡事件的特例toggle无法实现阻止冒泡——slideDown()和slideUp()

    一.问题 题目及答案展示:要求,点击题目,展开答案.如下: 展开前 展开后 最开始使用的toggle方法来实现 $(".content_problem").toggle( func ...

  2. [C/CPP系列知识] Type difference of character literals 和 bool in C and C++

    C/C+中的每一个常亮(every literal)都是有类型的,例如10 就是int型的,因此siziof(10)和sizeof(int)是相同的,但是字符型常亮(‘a’)在C和C++中有不同的变量 ...

  3. Linux操作系统下软件的安装方法大全

    一.rpm包安装方式步骤: 1.找到相应的软件包,比如soft.version.rpm,下载到本机某个目录: 2.打开一个终端,su -成root用户: 3.cd soft.version.rpm所在 ...

  4. 【IOC--Common Service Locator】不依赖于某个具体的IoC

    你在你的应用程序应用IoC容器了吗,你是否希望不依赖于某个具体的IoC,微软的模式与实践团队在Codeplex上发布的Common Service Locator.Common Service Loc ...

  5. 国内最大的 Node.js 社区将 New Relic 的监控产品换成了 OneAPM

    国内最知名的 CNode 社区把 New Relic 的监控产品换成了 OneAPM .难道 APM 的老大 New Relic 已经被 OneAPM 超越? 毋庸置疑,在全球应用性能管理 SaaS ...

  6. 谈谈WCF中的Data Contract(3):WCF Data Contract对Collection & Dictionary的支持

    谈谈WCF中的Data Contract(3):WCF Data Contract对Collection & Dictionary的支持 在本篇文章上一部分Order Processing的例 ...

  7. 【QT】视频播放+文件选择

    折腾了两个小时,太久没用了,找了半天的感觉. 先是在视频播放 的代码基础上加选择视频的按钮,开始总是显示两个框,后来发现需要用QSplitter来实现同时有多个框的情况. 把中心窗口设为这个split ...

  8. 【hadoop2.6.0】一句话形容mapreduce

    网上看到的: We want to count all the books in the library. You count up shelf #1, I count up shelf #2. Th ...

  9. 在实体注解OneToMany时,要加上mappedby,避免产生中间表。

    在实体注解OneToMany时,要加上mappedby,避免产生中间表.

  10. http://blog.csdn.net/superhosts/article/details/15813247

    http://blog.csdn.net/superhosts/article/details/15813247