Educational Codeforces Round 19 C】的更多相关文章

题目链接:http://codeforces.com/contest/797 A题 题意:给出两个数n, k,问能不能将n分解成k个因子相乘的形式,不能输出-1,能则输出其因子: 思路:将n质因分解,若质因子数目对于k则可行,随便将其组合成k个因子即可,反之则不行: 代码: #include <bits/stdc++.h> using namespace std; const int MAXN=1e5; int a[MAXN]; int main(void){ ; cin >> n…
A. k-Factorization 题目大意:给一个数n,求k个大于1的数,乘积为n.(n<=100,000,k<=20) 思路:分解质因数呗 #include<cstdio> #define MN 100000 ],an; int main() { int n,k,i; scanf("%d%d",&n,&k); ;k>&&n>;++i)&&n%i==;--k,n/=i)a[++an]=i; )*pu…
A. k-Factorization 题意:给你一个n,问你这个数能否分割成k个大于1的数的乘积. 题解:因为n的取值范围很小,所以感觉dfs应该不会有很多种可能-- #include<bits/stdc++.h> using namespace std; long long n; int k; vector<int> ans; void dfs(int x,long long now,int st){ if(x==k&&now==n){ for(int i=0;i…
这场edu蛮简单的…… 连道数据结构题都没有…… A.随便质因数分解凑一下即可. #include<bits/stdc++.h> #define N 100005 using namespace std; int a[N],cnt,k,x,n; int main(){ scanf("%d%d",&n,&k); ;k>&&n>;i++) &&n%i==;--k,n/=i)a[++cnt]=i; ){puts(;} ;…
A. k-Factorization 题意:将n分解成k个大于1的数相乘的形式.如果无法分解输出-1. 思路:先打个素因子表,然后暴力判,注意最后跳出的条件. int len,a[N],b[N]; void init() { memset(a,-1,sizeof(a)); a[0]=a[1]=0; memset(b,0,sizeof(b)); len=0; for(int i=2; i<N; i++) if(a[i]) { b[len++]=i; if(N/i<i) continue; for…
Description Petya recieved a gift of a string s with length up to 105 characters for his birthday. He took two more empty strings t and u and decided to play a game. This game has two possible moves: Extract the first character of s and append t with…
Description You are given sequence a1, a2, ..., an of integer numbers of length n. Your task is to find such subsequence that its sum is odd and maximum among all such subsequences. It's guaranteed that given sequence contains subsequence with odd su…
Description Given a positive integer n, find k integers (not necessary distinct) such that all these integers are strictly greater than 1, and their product is equal to n. Input The first line contains two integers n and k (2 ≤ n ≤ 100000, 1 ≤ k ≤ 20…
传送门 题意 给出n个数,q个询问,每个询问有两个数p,k,询问p+k+a[p]操作几次后超过n 分析 分块处理,在k<sqrt(n)时,用dp,大于sqrt(n)用暴力 trick 代码 #include<cstdio> int n,a[100100],p,k,q,dp[100100][350]; int main() { scanf("%d",&n); for(int i=1;i<=n;++i) scanf("%d",a+i);…
Educational Codeforces Round 17 A. k-th divisor 水题,把所有因子找出来排序然后找第\(k\)大 view code //#pragma GCC optimize("O3") //#pragma comment(linker, "/STACK:1024000000,1024000000") #include<bits/stdc++.h> using namespace std; function<voi…