快速竞技#4

A–Duff and Meat588A

= =这题不知道怎么写题解了。。

直接上code……….

#include<bits/stdc++.h>
#include<string.h>
using namespace std;
typedef long long LL;
typedef unsigned long long ULL;
const double eps=1e-5;
const double pi=acos(-1.0);
const int mod=1e8+7;
const LL INF=0x3f3f3f3f; const int N=1e3+10; int main()
{
int n;
int x,a,b;
x=INF;
scanf("%d",&n);
int ans=0;
for(int i=0;i<n;i++)
{
scanf("%d%d",&a,&b);
if(b<x)
x=b;
ans+=a*x;
}
printf("%d\n",ans);
return 0;
}

B——-Duff in Love588A

lovely number.:不能整除一个a^2(a>1)。

给出一个N(<=10^12),在他的因子里,求一个最大的lovely number.

思路:

不含平方因子就是说一种因子只能存在一个,所以说分解质因子然后一种因子取一个就好了。

学到一波:分解质因数;可以求所有质因数哟~~~

for(LL i=2;i*i<=n;i++)

{

if(n%i==0){

ans*=i;

while(n%i==0)

n/=i;

}

if(n==1)

break;

}

code………..

#include<bits/stdc++.h>
#include<string.h>
using namespace std;
typedef long long LL;
typedef unsigned long long ULL;
const double eps=1e-5;
const double pi=acos(-1.0);
const int mod=1e8+7;
const LL INF=0x3f3f3f3f; const int N=1e6+10;
int d[N]; int main()
{
int u,v;
LL n;
LL ans=1;
scanf("%I64d",&n);
for(LL i=2;i*i<=n;i++)
{
if(n%i==0){
ans*=i;
while(n%i==0)
n/=i;
}
if(n==1)
break;
}
if(n>1)
ans*=n;
printf("%I64d\n",ans);
return 0;
}

F: 584C - Marina and Vasya

题意:

求一个字符串和s1,s2有t个不同;

思路:

直接搞;还是蛮清楚的构造。

code…………..

#include<bits/stdc++.h>
#include<string.h>
using namespace std;
typedef long long LL;
typedef unsigned long long ULL;
const double eps=1e-5;
const double pi=acos(-1.0);
const int mod=1e8+7;
const LL INF=0x3f3f3f3f; const int N=1e5+10; char s1[N],s2[N],ans[N];
bool status[N]; char kill(char a,char b)
{
for(int i='a';i<='z';i++)
{
if(i!=a&&i!=b)
return i;
}
} int main()
{
int n,t,sum;
scanf("%d%d",&n,&t);
scanf("%s%s",s1,s2);
sum=0;
memset(status,0,sizeof(status));
for(int i=0;i<n;i++)
{
if(s1[i]!=s2[i])
sum++;
else
status[i]=1;
}
if(sum==t)
{
for(int i=0;i<n;i++)
{
if(status[i])
ans[i]=s1[i];
else
ans[i]=kill(s1[i],s2[i]);
}
}
else if(sum<t){ //补齐t-sum;
int cnt=0;
for(int i=0;i<n;i++)
{
if(status[i])
{
if(cnt<(t-sum))
{
ans[i]=kill(s1[i],s2[i]);
cnt++;
}
else
ans[i]=s1[i];
}
else
ans[i]=kill(s1[i],s2[i]);
}
}
else{ //不同的多了t-sum
int cnt1=0,cnt2=0; //把两个串都补齐,可能补不齐,所以最后还要判断。
for(int i=0;i<n;i++)
{
if(status[i])
ans[i]=s1[i];
else
{
if(cnt1<(sum-t))
{
ans[i]=s1[i];
cnt1++;
}
else if(cnt2<(sum-t))
{
ans[i]=s2[i];
cnt2++;
}
else
ans[i]=kill(s1[i],s2[i]);
}
}
}
int sum1=0,sum2=0;
for(int i=0;i<n;i++)
{
if(s1[i]!=ans[i])
sum1++;
if(s2[i]!=ans[i])
sum2++;
}
if(sum1!=t||sum2!=t)
{
puts("-1");
return 0;
}
ans[n]='\0';
printf("%s",ans);
return 0;
}

Codeforces 快速竞技#4的更多相关文章

  1. 某神奇的cf跳转插件

    // ==UserScript== // @name Codeforces快速跳转菜单 // @namespace http://tampermonkey.net/ // @version 2019. ...

  2. CodeForces 450B (矩阵快速幂模板题+负数取模)

    题目链接:http://acm.hust.edu.cn/vjudge/problem/viewProblem.action?id=51919 题目大意:斐波那契数列推导.给定前f1,f2,推出指定第N ...

  3. codeforces magic five --快速幂模

    题目链接:http://codeforces.com/contest/327/problem/C 首先先算出一个周期里面的值,保存在ans里面,就是平常的快速幂模m做法. 然后要计算一个公式,比如有k ...

  4. codeforces 677C C. Vanya and Label(组合数学+快速幂)

    题目链接: C. Vanya and Label time limit per test 1 second memory limit per test 256 megabytes input stan ...

  5. Educational Codeforces Round 13 D. Iterated Linear Function (矩阵快速幂)

    题目链接:http://codeforces.com/problemset/problem/678/D 简单的矩阵快速幂模版题 矩阵是这样的: #include <bits/stdc++.h&g ...

  6. Codeforces Round #257 (Div. 2) B. Jzzhu and Sequences (矩阵快速幂)

    题目链接:http://codeforces.com/problemset/problem/450/B 题意很好懂,矩阵快速幂模版题. /* | 1, -1 | | fn | | 1, 0 | | f ...

  7. Educational Codeforces Round 60 (Rated for Div. 2) - D. Magic Gems(动态规划+矩阵快速幂)

    Problem   Educational Codeforces Round 60 (Rated for Div. 2) - D. Magic Gems Time Limit: 3000 mSec P ...

  8. Codeforces Round #536 (Div. 2) F 矩阵快速幂 + bsgs(新坑) + exgcd(新坑) + 欧拉降幂

    https://codeforces.com/contest/1106/problem/F 题意 数列公式为\(f_i=(f^{b_1}_{i-1}*f^{b_2}_{i-2}*...*f^{b_k} ...

  9. Educational Codeforces Round 60 D dp + 矩阵快速幂

    https://codeforces.com/contest/1117/problem/D 题意 有n个特殊宝石(n<=1e18),每个特殊宝石可以分解成m个普通宝石(m<=100),问组 ...

随机推荐

  1. booth乘法器原理

    在微处理器芯片中,乘法器是进行数字信号处理的核心,同一时候也是微处理器中进行数据处理的wd=%E5%85%B3%E9%94%AE%E9%83%A8%E4%BB%B6&hl_tag=textli ...

  2. 关于 redux-saga 中 take 使用方法详解

    本文介绍了关于redux-saga中take使用方法详解,分享给大家,具体如下: 带来一个自己研究好久的API使用方法. redux-saga中effect中take这个API使用方式,用的多的是ca ...

  3. ConcurrentHashMap源代码解析

    这些天一直在看集合相关的源代码.确实学到了不少东西.这些集合都是息息相关的,学了就停不下来! 学集合就必须要学习锁的知识.学了锁那么并发编程的知识也不能少,都是非常重要的基础知识. jdk1.8的源代 ...

  4. Django-配置celery

    首先需要安装的包 pip install cellerypip install django-cellery pip install django-cellery-results pip instal ...

  5. Linux fork函数具体图解-同一时候分析一道腾讯笔试题

    原创blog.转载请注明出处 头文件: #include<unistd.h> #include<sys/types.h> 函数原型: pid_t fork( void); (p ...

  6. PrintWrite

    向文本输出流打印对象的格式化表示形式.此类实现在 PrintStream 中的所有 print 方法.它不包含用于写入原始字节的方法,对于这些字节,程序应该使用未编码的字节流进行写入. 与 Print ...

  7. 贞鱼传教&&贞鱼传教(数据加强版)

    http://acm.buaa.edu.cn/problem/1381/ 贞鱼传教[问题描述] 新的一年到来了,贞鱼哥决定到世界各地传授“贞教”,他想让“贞教”在2016年成为世界第四大宗教.说干就干 ...

  8. C/S转分布式数据库的解决方法

    C/S转分布式数据库的解决方法1. 直接VPN建一个网不就行了.(大概是虚拟成一个网络)2. 直连也可以,就是速度慢3. 还是三层吧,推荐RTC4. 弄个花生壳硬件试试呢,成本低,不用改程序5. 搞一 ...

  9. Spring Boot2.0之 整合Redis事务

    Redis事物 Redis 事务可以一次执行多个命令, 并且带有以下两个重要的保证: 事务是一个单独的隔离操作:事务中的所有命令都会序列化.按顺序地执行.事务在执行的过程中,不会被其他客户端发送来的命 ...

  10. android之View坐标系(view获取自身坐标的方法和点击事件中坐标的获取)

    在做一个view背景特效的时候被坐标的各个获取方法搞晕了,几篇抄来抄去的博客也没弄很清楚. 现在把整个总结一下. 其实只要把下面这张图看明白就没问题了. 涉及到的方法一共有下面几个: view获取自身 ...