fzu 1675 The Seventy-seven Problem
给你长度为 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的更多相关文章
- FZU 2224 An exciting GCD problem(GCD种类预处理+树状数组维护)同hdu5869
题目链接:http://acm.fzu.edu.cn/problem.php?pid=2224 同hdu5869 //#pragma comment(linker, "/STACK:1024 ...
- FZU 2240 Daxia & Suneast's problem
博弈,$SG$函数,规律,线段树. 这个问题套路很明显,先找求出$SG$函数值是多少,然后异或起来,如果是$0$就后手赢,否则先手赢.修改操作和区间查询的话可以用线段树维护一下区间异或和. 数据那么大 ...
- 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 ...
- 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 ...
- HITtrainning20140417题解
题目列表: ID Origin Title 10 / 15 Problem A FZU 2152 文件系统 0 / 16 Problem B FZU 2153 A simple geome ...
- (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 ...
- fzu Problem 2148 Moon Game(几何 凸四多边形 叉积)
题目:http://acm.fzu.edu.cn/problem.php?pid=2148 题意:给出n个点,判断可以组成多少个凸四边形. 思路: 因为n很小,所以直接暴力,判断是否为凸四边形的方法是 ...
- fzu Problem 2140 Forever 0.5(推理构造)
题目:http://acm.fzu.edu.cn/problem.php?pid=2140 题意: 题目大意:给出n,要求找出n个点,满足: 1)任意两点间的距离不超过1: 2)每个点与(0,0)点的 ...
- 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 ...
随机推荐
- gcd 最大公约数 模版!
1: #define ll long long ll gcd(ll a,ll b) { ) { return b; }else { return gcd(b % a,a); } } 2: int64 ...
- hdu 4578 Transformation 线段树
没什么说的裸线段树,注意细节就好了!!! 代码如下: #include<iostream> #include<stdio.h> #include<algorithm> ...
- BZOJ 3203 sdoi 2013 保护出题人
由于样例解释很清晰,所以很容易得到以下结论: 1.每一关都是独立的,且僵尸的相对位置不会变 2.每一关的攻击力=Max(sum(i)/dis(i)) 其实sum(i)是僵尸攻击力的前缀和,dis(i) ...
- 【Linux高频命令专题(15)】more
more命令,功能类似 cat ,cat命令是整个文件的内容从上到下显示在屏幕上. more会以一页一页的显示方便使用者逐页阅读,而最基本的指令就是按空白键(space)就往下一页显示,按 b 键就会 ...
- Debug模式应用程序输出Debug调试信息(现成的宏定义,用于格式化打印信息)
// Debug模式,主要输出一些调试的信息. #ifdef UNICODE #define _FILE_ _STR2WSTR(__FILE__) #define _FUNCTION ...
- VIM树状文件列表NERDTree
下载和配置 NERDTree插件的官方地址如下,可以从这里获取最新的版本 https://github.com/scrooloose/nerdtree 下载zip安装包 或者使用下面官网源文件安装方法 ...
- iOS iOS7越狱
1.使用盘古越狱工具 (或者PP助手) 2.越狱成功后需要安装Apple File Conduit “2”,用于替代afc2add插件 3.安装AppSync插件 (绕过系统验证,随意安装.运行破解的 ...
- 在VS2012后的版本中做数据报表时,提示尚未指定报表“Report1”的报表定义
有一群的朋友在用VS2012做数据报表时,老是提示 本地报表处理期间出错. 尚未指定报表“Report1”的报表定义 未将对象引用设置到对象的实例. 我看了一下,步骤没错,我用VS2010做了一下,一 ...
- MySql开启跟踪
使用 show variables like '%log%'; 查看general_log.log_output.general_log_file 更新为 set global general_log ...
- RecyclerView(6)自定义RecyclerView.LayoutManager
A LayoutManager is responsible for measuring and positioning item views within a RecyclerView as wel ...