Codeforces Round #395 A

Taymyr is calling you

题意:给你n,m求不超过z的即是n的倍数又是m的倍数的树有多少个

思路:z/(n*m) *gcd(n,m)小学奥数题,或者直接暴力也可以

AC代码:

#include "iostream"
#include "string.h"
#include "stack"
#include "queue"
#include "string"
#include "vector"
#include "set"
#include "map"
#include "algorithm"
#include "stdio.h"
#include "math.h"
#define ll long long
#define bug(x) cout<<x<<" "<<"UUUUU"<<endl;
#define mem(a) memset(a,0,sizeof(a))
#define mp(x,y) make_pair(x,y)
#define pb(x) push_back(x)
using namespace std;
const long long INF = 1e18+1LL;
const int inf = 1e9+1e8;
const int N=1e5+100;
const ll mod=1e9+7;

int n,m,z,ans;
int main(){
    ios::sync_with_stdio(false),cin.tie(0),cout.tie(0);
    cin>>n>>m>>z;
    cout<<z*__gcd(n,m)/(n*m)<<endl;
    return 0;
}
时间: 2024-08-29 10:51:21

Codeforces Round #395 A的相关文章

Codeforces Round #395 C. Timofey and a tree

package codeforces; import java.util.*; public class CodeForces_764C_Timofey_and_a_tree { static final int N=(int) (2e5+10); @SuppressWarnings("unchecked") static ArrayList<Integer> a[]=new ArrayList[N]; static int book[]=new int[N]; stati

Codeforces Round #395 (Div. 2) C

题意 : 给出一颗树 每个点都有一个颜色 选一个点作为根节点 使它的子树各自纯色 我想到了缩点后check直径 当<=3的时候可能有解 12必定有解 3的时候需要check直径中点的组成点里是否有一个点连接了另外所有的点 如果有就是ans 没有就是no 这个方法是对了 不过比较麻烦..需要很多check 但是看div1的做法 有很棒的姿势用来解这个题 扫一下所有的边 如果两边的点颜色不一样 就增加一个连通分量数 这样可以很方便的算出有多少连通分量 同时记录这个点连着多少个其余的颜色(连通分量)

Codeforces Round #395 (Div. 2) D

Description One of Timofey's birthday presents is a colourbook in a shape of an infinite plane. On the plane n rectangles with sides parallel to coordinate axes are situated. All sides of the rectangles have odd length. Rectangles cannot intersect, b

Codeforces Round #395 (Div. 2) 解题报告

年后恢复训练参加的第一场,表现的不是很好,必须要赶紧振作起来了啊. A.B题不再赘述. C题 不要被树的形式吓到,实际上不需要换根DFS,只需要看两顶点颜色不同的线段即可. 1 #include<stdio.h> 2 #include<bits/stdc++.h> 3 #include <iostream> 4 using namespace std; 5 typedef long long ll; 6 typedef unsigned long long ull; 7

【树形DP】Codeforces Round #395 (Div. 2) C. Timofey and a tree

先把1看作根. 预处理出f[i]表示以i为根的子树是什么颜色,如果是杂色的话,就是0. 然后从根节点开始转移,转移到某个子节点时,如果其子节点都是纯色,并且它上面的那一坨结点也是纯色,就输出解. 否则如果其上面的一坨是纯色,并且其子节点有且只有一个杂色的时候,就递归处理该子节点. #include<cstdio> #include<cstdlib> using namespace std; #define N 100050 int v[N<<1],first[N],ne

Codeforces Round #395 (Div. 2)(未完)

2.2.2017 9:35~11:35 A - Taymyr is calling you 直接模拟 #include <iostream> #include <cstdio> #include <algorithm> #include <cstring> #include <cmath> using namespace std; typedef long long ll; const int N=1e4+5; inline int read()

Codeforces Round #395 B

Timofey and cubes 题意: 思路:第奇数位数都没有改变位置,偶数位都与n-i+1调换了位置 AC代码: #include "iostream" #include "string.h" #include "stack" #include "queue" #include "string" #include "vector" #include "set"

Codeforces Round #395 (Div. 2)

今天自己模拟了一套题,只写出两道来,第三道时间到了过了几分钟才写出来,啊,太菜了. A. Taymyr is calling you 水题,问你在z范围内  两个序列  n,2*n,3*n......  和 m,2*m,3*m.....有多少个是一样的. #include<bits/stdc++.h> using namespace std; int n,m,z; int main() { cin>>n>>m>>z; int gcd=__gcd(n,m);

Codeforces Round #279 (Div. 2) ABCD

Codeforces Round #279 (Div. 2) 做得我都变绿了! Problems # Name     A Team Olympiad standard input/output 1 s, 256 MB  x2377 B Queue standard input/output 2 s, 256 MB  x1250 C Hacking Cypher standard input/output 1 s, 256 MB  x740 D Chocolate standard input/