A

#include <bits/stdc++.h>
#define PI acos(-1.0)
#define mem(a,b) memset((a),b,sizeof(a))
#define TS printf("!!!\n")
#define pb push_back
#define inf 1e9
//std::ios::sync_with_stdio(false);
using namespace std;
//priority_queue<int,vector<int>,greater<int>> que; get min
const double eps = 1.0e-8;
typedef pair<int, int> pairint;
typedef long long ll;
typedef unsigned long long ull;
//const int maxn = 3e5 + 10;
const int maxm = ;
const int turn[][] = {{, }, { -, }, {, }, {, -}};
//priority_queue<int, vector<int>, less<int>> que;
//next_permutation
ll mod = 3e7;
int weight;
int from,to;
vector<pair<int,int> > place[];
int main()
{
int anser=;
int n;
cin >> n;
for(int i=; i<=n; i++)
{
if(n%i==)
anser++;
}
cout<<anser<<endl;
}

B

#include <bits/stdc++.h>
#define PI acos(-1.0)
#define mem(a,b) memset((a),b,sizeof(a))
#define TS printf("!!!\n")
#define pb push_back
#define inf 1e9
//std::ios::sync_with_stdio(false);
using namespace std;
//priority_queue<int,vector<int>,greater<int>> que; get min
const double eps = 1.0e-8;
typedef pair<int, int> pairint;
typedef long long ll;
typedef unsigned long long ull;
//const int maxn = 3e5 + 10;
const int maxm = ;
const int turn[][] = {{, }, { -, }, {, }, {, -}};
//priority_queue<int, vector<int>, less<int>> que;
//next_permutation
ll mod = 3e7;
int num[];
int check(int x,int y)
{
if(x==y)
return ;
if(x>y)
return ;
return ;
}
int main()
{
int n;
int anser=;
int nowx,nowy;
nowx=nowy=;
cin >> n;
string a;
cin >> a;
int now=;
int belong=;
for(int i=; i<n; i++)
{
if(a[i]=='U')
nowy++;
else
nowx++;
belong=check(nowx,nowy);
num[i]=belong;
if(i>=)
if(num[i]+num[i-]==)
anser++;
// cout<<i<<" "<<nowx<<" "<<nowy<<endl;
// cout<<anser<<endl;
}
cout<<anser<<endl;
}

C

简单几何 题意题

给你一个圆和一个点,让你在给定圆内画一个圆,使得答案圆不能包含给定点,而且使得给定圆没有被答案圆覆盖的面积最小。输出答案圆的圆心和半径即可。

#include <bits/stdc++.h>
#define PI acos(-1.0)
#define mem(a,b) memset((a),b,sizeof(a))
#define TS printf("!!!\n")
#define pb push_back
#define inf 1e9
//std::ios::sync_with_stdio(false);
using namespace std;
//priority_queue<int,vector<int>,greater<int>> que; get min
const double eps = 1.0e-8;
typedef pair<int, int> pairint;
typedef long long ll;
typedef unsigned long long ull;
//const int maxn = 3e5 + 10;
const int maxm = ;
const int turn[][] = {{, }, { -, }, {, }, {, -}};
//priority_queue<int, vector<int>, less<int>> que;
//next_permutation
ll mod = 3e7;
int num[];
int main()
{
double R,x1,x2,y1,y2;
cin >>R >> x1 >> y1 >> x2 >> y2;
double xap,yap,r;
double len=(x1-x2)*(x1-x2)+(y1-y2)*(y1-y2);
double dis1=sqrt(len);
if(len>=R*R)
{
printf("%.7f %.7f %lf",x1,y1,R);
return ;
}
if(x1==x2&&y1==y2)
{
printf("%.7f %.7f %.7f",x1+R/,y1,R/);
return ;
}
r=(R+dis1)/2.0;
xap=x2+(x1-x2)*(r/dis1);
yap=y2+(y1-y2)*(r/dis1);
printf("%.7f %.7f %lf",xap,yap,r);
}

D

给你两个长为N包含0的数字串 0可以变化为1-k的任何数

要求你求出第一个串比第二个大的可能性(一个分数)模上1e9+7

总共的可能性数量很好想 是K的0数量次方 再把分数转化为求逆元就变为:比原串大的方案数乘以 总方案数对MOD的逆元 模MOD

dp[i][0]表示到第i个两个字典序相等的方案数 dp[i][1]表示到第i个第一个比第二个字典序大的方案数

dp[i][1]可以由dp[i-1][0]与dp[i-1][1]转换而来 而 dp[i][0]只能由dp[i-1][0]转换而来

所以分类讨论

1.a=ai b=bi时

相等时

dp[i][0]=dp[i-1][0]

dp[i][1]=dp[i-1][1]

前大于后时

dp[i][1]=dp[i-1][0]+dp[i-1][1]

dp[i][0]=0

后大于前时

dp[i][1]=dp[i][0]=0

2.a=0 b=bi时

dp[i][0]=dp[i-1][0]

dp[i][1]=dp[i-1][1]*k+dp[i-1][0]*(k-bi)

3.a=ai b=0时

dp[i][0]=dp[i-1][0]

dp[i][1]=dp[i-1][1]*k+dp[i-1][0]*(b-1)

4.a=b=0

dp[i][0]=dp[i-1][0]*k

dp[i][1]=dp[i-1][1]*k*k+dp[i-1][0]*(k-1)*k/2

一直dp到n

#include <bits/stdc++.h>
#define PI acos(-1.0)
#define mem(a,b) memset((a),b,sizeof(a))
#define TS printf("!!!\n")
#define pb push_back
#define inf 1e9
//std::ios::sync_with_stdio(false);
using namespace std;
//priority_queue<int,vector<int>,greater<int>> que; get min
const double eps = 1.0e-8;
typedef pair<int, int> pairint;
typedef long long ll;
typedef unsigned long long ull;
const int turn[][] = {{, }, { -, }, {, }, {, -}};
//priority_queue<int, vector<int>, less<int>> que;
//next_permutation
const int mod = 1e9+;
int sum=;
ll dp[][];
int num[][];
ll quickpow(ll x,ll n)
{
ll res=;
while(n)
{
if(n&)res=res*x%mod;
x=x*x%mod;
n/=;
}
return res;
}
int main()
{
ll n,m;
cin >> n >> m;
for(int i=; i<=; i++)
for(int j=; j<=n; j++)
{
scanf("%d",&num[i][j]);
}
mem(dp,);
dp[][]=;
for(int i=; i<=n; i++)
{
sum+=(num[][i]==);
sum+=(num[][i]==);
if(num[][i]&&num[][i])
{
if(num[][i]==num[][i])
{
dp[i][]=dp[i-][];
dp[i][]=dp[i-][];
}
else if(num[][i]>num[][i])
{
dp[i][]=(dp[i-][]+dp[i-][])%mod;
dp[i][]=;
}
else
{
dp[i][]=;
dp[i][]=dp[i-][];
}
}
else if(num[][i]==&&num[][i]==)
{
dp[i][]=dp[i-][]*m%mod;
dp[i][]=((dp[i-][]*((m*m)%mod)%mod+dp[i-][]*((m-)*m/)%mod)%mod)%mod;
}
else if(num[][i]==)
{
dp[i][]=dp[i-][]%mod;
dp[i][]=(dp[i-][]*m%mod+dp[i-][]*(m-num[][i])%mod)%mod;
}
else if(num[][i]==)
{
dp[i][]=dp[i-][]%mod;
dp[i][]=(dp[i-][]*m%mod+dp[i-][]*(num[][i]-)%mod)%mod;
}
}
ll anser=dp[n][]*quickpow(quickpow(m,sum),mod-)%mod;
cout<<anser<<endl;
}

Codeforces 935 简单几何求圆心 DP快速幂求与逆元的更多相关文章

  1. 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} ...

  2. 【bzoj4870】[Shoi2017]组合数问题 dp+快速幂/矩阵乘法

    题目描述 输入 第一行有四个整数 n, p, k, r,所有整数含义见问题描述. 1 ≤ n ≤ 10^9, 0 ≤ r < k ≤ 50, 2 ≤ p ≤ 2^30 − 1 输出 一行一个整数 ...

  3. codeforce 227E 矩阵快速幂求斐波那契+N个连续数求最大公约数+斐波那契数列的性质

    E. Anniversary time limit per test2 seconds memory limit per test256 megabytes inputstandard input o ...

  4. HDU4869:Turn the pokers(快速幂求逆元+组合数)

    题意: 给出n次翻转和m张牌,牌相同且一开始背面向上,输入n个数xi,表示xi张牌翻转,问最后得到的牌的情况的总数. 思路: 首先我们可以假设一开始牌背面状态为0,正面则为1,最后即是求ΣC(m,k) ...

  5. POJ-3070Fibonacci(矩阵快速幂求Fibonacci数列) uva 10689 Yet another Number Sequence【矩阵快速幂】

    典型的两道矩阵快速幂求斐波那契数列 POJ 那是 默认a=0,b=1 UVA 一般情况是 斐波那契f(n)=(n-1)次幂情况下的(ans.m[0][0] * b + ans.m[0][1] * a) ...

  6. 小白月赛13 小A的路径 (矩阵快速幂求距离为k的路径数)

    链接:https://ac.nowcoder.com/acm/contest/549/E来源:牛客网 时间限制:C/C++ 1秒,其他语言2秒 空间限制:C/C++ 262144K,其他语言52428 ...

  7. hdu 2065 "红色病毒"问题(快速幂求模)

    n=1  --> ans = 2 = 1*2 = 2^0(2^0+1) n=2  -->  ans = 6 = 2*3 = 2^1(2^1+1) n=3  -->  ans = 20 ...

  8. Product Oriented Recurrence(Codeforces Round #566 (Div. 2)E+矩阵快速幂+欧拉降幂)

    传送门 题目 \[ \begin{aligned} &f_n=c^{2*n-6}f_{n-1}f_{n-2}f_{n-3}&\\ \end{aligned} \] 思路 我们通过迭代发 ...

  9. hdu4686 简单的矩阵快速幂求前n项和

    HDU4686 题目链接:http://acm.hdu.edu.cn/showproblem.php?pid=4686 题意:题目说的很清楚了,英语不好的猜也该猜懂了,就是求一个表达式的前n项和,矩阵 ...

随机推荐

  1. node、npm、git版本升级

    node版本升级: npm install -g n 或者 npm i -g n --force n stable或者n --stable:安装最近稳定版本 n latest或者n --latest: ...

  2. Vue创建局部组件

    <!DOCTYPE html> <html lang="en"> <head> <meta charset="UTF-8&quo ...

  3. 阶段3 1.Mybatis_11.Mybatis的缓存_7 触发清空一级缓存的情况

    如果数据库的数据和一级缓存的数据不一致了,怎么做到同步的呢? 增加一个更新 用户信息的方法 增加更新的节点配置 测试类增加测试方法.先查询id为41的 然后更新了41的数据.再次查询41的数据 先把更 ...

  4. oracle-不完全数据库恢复-被动恢复-ORA-00313/ORA-00366

    继上一篇不完全恢复 oracle-不完全数据库恢复-被动恢复-ORA-00313/ORA-00366 场景2:数据库拥有备份,CURRENT状态日志组中所有的在线日志头损坏,在发生日志切换时实例被自动 ...

  5. Scala的to和until

    object test03 { def main(args: Array[String]): Unit = { //to 每次迭代为1 val to1= to print("to1" ...

  6. html5获取位置信息,h5获取位置信息

    <!DOCTYPE html> <html> <head> <meta charset="utf-8"> <title> ...

  7. MySQL知识集合

    1.Mysql体系架构     2.MySQL文件结构 (1)参数文件:启动MySQL实例的时候,指定一些初始化参数,比如缓冲池大小.数据库文件路径.用户名密码等         -my.cnf读取优 ...

  8. redis在ubuntu下的安装

    安装: 1.apt-get install redis 2.接下来输入redis-cli,登陆redis,然后就可以操作redis了 卸载 在ubuntu下卸载redis 1. 卸载软件 apt-ge ...

  9. redis学习(二)

    深入了解redis字符串,列表,散列和有序集合命令,了解发布,订阅命令和其他命令.   一,字符串   1.字符串可以存储3种类型的值 字符串,整数,浮点数 2.运算命令列表 incr : incr ...

  10. Pyinstaller-封装python

    1. 当程序中没有调用matplotlib模块 ① pip intall pyinstaller ② 在cmd环境下,pyinstaller -F  xxx.py 2.当程序中调用matplotlib ...