CodeForces 111B - Petya and Divisors 统计..想法题
找每个数的约数(暴力就够了...1~x^0.5)....看这约数的倍数最后是哪个数...若距离大于了y..统计++...然后将这个约数的最后倍数赋值为当前位置...好叼的想法题....
Program:
#include<iostream>
#include<stack>
#include<queue>
#include<stdio.h>
#include<algorithm>
#include<string.h>
#include<cmath>
#define ll long long
#define oo 1000000007
#define MAXN 100005
using namespace std;
int last[MAXN];
int main()
{
int T,t;
scanf("%d",&T);
memset(last,-1,sizeof(last));
for (t=1;t<=T;t++)
{
int x,y,ans,i,p;
ans=0;
scanf("%d%d",&x,&y);
for (i=1;i*i<=x;i++)
if (x%i==0)
{
if (t-last[i]>y) ans++;
if (x-i*i && t-last[x/i]>y) ans++;
last[i]=last[x/i]=t;
}
printf("%d\n",ans);
}
return 0;
}
CodeForces 111B - Petya and Divisors 统计..想法题的更多相关文章
- CodeForces - 669D Little Artem and Dance 想法题 多余操作
http://codeforces.com/problemset/problem/669/D 题意:n个数1~N围成一个圈.q个操作包括操作1:输入x, 所有数右移x.操作2:1,2位置上的数(swa ...
- CodeForces 342A Xenia and Divisors (水题)
题意:给定 n 个数(小于等于7),让你把它分成 m 组,每组有三个数,且满足,a < b < c,并且 a 能整除 b,b 能整除 c. 析:对于这个题,因为题目说了是不大于7的,那么一 ...
- codeforces 111B/112D Petya and Divisors
题目:Petya and Divisors传送门: http://codeforces.com/problemset/problem/111/B http://codeforces.com/probl ...
- Codeforces Beta Round #85 (Div. 1 Only) B. Petya and Divisors 暴力
B. Petya and Divisors Time Limit: 20 Sec Memory Limit: 256 MB 题目连接 http://codeforces.com/contest/111 ...
- HDU 4972 Bisharp and Charizard 想法题
Bisharp and Charizard Time Limit: 1 Sec Memory Limit: 256 MB Description Dragon is watching NBA. He ...
- codeforces 703E Mishka and Divisors
codeforces 703E Mishka and Divisors 题面 给出大小为\(1000\)的数组和一个数\(k\),求长度最短的一个子序列使得子序列的元素之积是\(k\)的倍数,如果有多 ...
- Codeforces Round #609 (Div. 2)前五题题解
Codeforces Round #609 (Div. 2)前五题题解 补题补题…… C题写挂了好几个次,最后一题看了好久题解才懂……我太迟钝了…… 然后因为longlong调了半个小时…… A.Eq ...
- B. Petya and Divisors 解析(思維)
Codeforce 111 B. Petya and Divisors 解析(思維) 今天我們來看看CF111B 題目連結 題目 略,請看原題 前言 看了別人的解答就豁然開朗 @copyright p ...
- HDU - 5806 NanoApe Loves Sequence Ⅱ 想法题
http://acm.hdu.edu.cn/showproblem.php?pid=5806 题意:给你一个n元素序列,求第k大的数大于等于m的子序列的个数. 题解:题目要求很奇怪,很多头绪但写不出, ...
随机推荐
- C#代码 json类
using System; using System.Collections.Generic; using System.Collections; using System.Text; using S ...
- xcode 5与ios 7的屏幕适配问题
#define DEVICE_IS_IPHONE5 ([[UIScreen mainScreen] bounds].size.height == 568) float height = DEVICE_ ...
- 网路流程图 TCP/IP
- LInux 下挂在Windows共享文件夹
挂载WIndow共享文件夹 //192.168.0.103/software mount -t smbfs -o username=administrator,password=“de123” / ...
- windows 2003 server 安装 .NET Framework 2.0环境
下载net2.0安装包,这里提供官方下载地址: http://www.microsoft.com/zh-cn/download/confirmation.aspx?id=1639 然后运行exe文件, ...
- 学习本课程需要具备哪些基础及微信小程序目录结构介绍
1.html css js 基础 2.ajax 基础 3.简单的面向对象基础
- MS SQL 当记录不存在时插入insert INTO not exists
INSERT INTO dbo.[T_DabaoTemp] ([PType] ,[pID] ,[NewVersion] ,[ParentC ...
- 【深搜加剪枝】【HDU1455】【Sticks】
题目大意:有一堆木棍 由几个相同长的木棍截出来的,求那几个相同长的木棍最短能有多短? 深搜+剪枝 具体看代码 #include <cstdio> #include <cstdlib& ...
- AES 加密,C#后台,javascript前台,crypt-js
javascript前台代码 <script src="http://apps.bdimg.com/libs/crypto-js/3.1.2/components/core-min.j ...
- HTML网页制作:[12]使用框架结构之frameset
首先,我希望在你的目录下,有4个网页,各自显示不同的内容. 如图所示: 1.html显示“火影忍者” 2.html显示“英雄联盟” 3.html显示“嵌入式开发.网页开发.安卓开发” 4.html显示 ...