ural Infernal Work
Time Limit:2000MS Memory Limit:65536KB 64bit IO Format:%I64d & %I64u
Description
Input
Output
Sample Input
| input | output |
|---|---|
3 4 10 |
4 |
2 4 10 |
0 |
Notes
#include <iostream>
using namespace std; struct Data{
long long zua;
long long zub;
};
//本题的思路是为两种不同的分组方式分别赋予不同的组别值,
//然后搜索符合题目要求的配对。
int main(){
long long a,b,n;
cin>>a>>b>>n;
Data data[n]; long long num1=,num2=;
for(long long i=;i<n;i++){
data[i].zua=num1;
data[i].zub=num2;
if((i+)%a==){
++num1;
}
if((i+)%b==){
++num2;
}
}
long long result=;
for(long long i=;i<n;i++){
for(long long j=i;j<n&&j<i+a;j++){
if(data[i].zua==data[j].zua&&data[i].zub!=data[j].zub){
++result;
}
}
}
cout<<result;
}
那么就用一个数组来实现它:
#include <iostream>
#include <cstring>
#include <algorithm>
using namespace std; int main(){
int a,b,n;
cin>>a>>b>>n;
long long result=;
bool qwe;
for(int i=;i<n;i=i+a){
int yb=i/b,k=,cur;
qwe=; for(int j=i+;j<i+a&&j<n;j++){
int yb2=j/b;
if(yb2==yb) continue;
if(!qwe){
cur=yb2;
k=j-i;
qwe=;
}
if(yb2!=cur){
k=j-i;
cur=yb2;
}
result+=k;
}
}
cout<<result<<endl;
}
ural Infernal Work的更多相关文章
- 后缀数组 POJ 3974 Palindrome && URAL 1297 Palindrome
题目链接 题意:求给定的字符串的最长回文子串 分析:做法是构造一个新的字符串是原字符串+反转后的原字符串(这样方便求两边回文的后缀的最长前缀),即newS = S + '$' + revS,枚举回文串 ...
- ural 2071. Juice Cocktails
2071. Juice Cocktails Time limit: 1.0 secondMemory limit: 64 MB Once n Denchiks come to the bar and ...
- ural 2073. Log Files
2073. Log Files Time limit: 1.0 secondMemory limit: 64 MB Nikolay has decided to become the best pro ...
- ural 2070. Interesting Numbers
2070. Interesting Numbers Time limit: 2.0 secondMemory limit: 64 MB Nikolay and Asya investigate int ...
- ural 2069. Hard Rock
2069. Hard Rock Time limit: 1.0 secondMemory limit: 64 MB Ilya is a frontman of the most famous rock ...
- ural 2068. Game of Nuts
2068. Game of Nuts Time limit: 1.0 secondMemory limit: 64 MB The war for Westeros is still in proces ...
- ural 2067. Friends and Berries
2067. Friends and Berries Time limit: 2.0 secondMemory limit: 64 MB There is a group of n children. ...
- ural 2066. Simple Expression
2066. Simple Expression Time limit: 1.0 secondMemory limit: 64 MB You probably know that Alex is a v ...
- ural 2065. Different Sums
2065. Different Sums Time limit: 1.0 secondMemory limit: 64 MB Alex is a very serious mathematician ...
随机推荐
- bootstrapcss3触屏滑块轮播图
插件描述:bootslider响应bootstrapcss3触屏滑块轮播图 小海已经好久没分享技术性文章了,这个基于bootstrap的触屏版轮播图绝对满足大家的胃口,并且支持移动端触摸滑动.功能上, ...
- 为Sharepoint 2010 批量创建SharePoint测试用户
无意搜到下面一篇文章,http://www.cnblogs.com/lambertqin/archive/2012/04/19/2457372.html,原作者写的太"高大上",可 ...
- Web自动化测试 Selenium 1/3
Selenium 名字的来源 在这里,我还想说一下关于 Selenium 名字的来源,很有意思的 : > : Selenium 的中文名为 “ 硒 ” ,是一种化学元素的名字,它 对 汞 ( M ...
- Android 触摸手势基础 官方文档概览
Android 触摸手势基础 官方文档概览 触摸手势检测基础 手势检测一般包含两个阶段: 1.获取touch事件数据 2.解析这些数据,看它们是否满足你的应用所支持的某种手势. 相关API: Moti ...
- 一个巧妙的实现悬浮的tableViewHeader的方法
之前因为工作需要要实现一个类似的 悬浮+视差的headerView的效果, 研究了好久没研究出来怎么做,最后用UICollectionView + CSStickyHeaderFlowLayout的方 ...
- Facebook开源动画库 POP-POPBasicAnimation运用
动画在APP开发过程中还是经常出现,将花几天的时间对Facebook开源动画库 POP进行简单的学习:本文主要针对的是POPBasicAnimation运用:实例源代码已经上传至gitHub,地址:h ...
- Android与JS之间跨平台异步调用
为什么突然要搞这个问题呢? 在开发浏览器的时候遇到这个狗血的问题,花了将近1天的时间才想到这个解决方案,Android与JavaScirpt互调. 因为接口是抓取的别人的,所以出现了JS跨域问题, ...
- 【代码笔记】iOS-点击搜索按钮,或放大镜后都会弹出搜索框
一, 效果图. 二,工程图. 三,代码. RootViewController.h #import <UIKit/UIKit.h> #import "CLHSearchBar.h ...
- OC中的内存管理
一. 基本原理 1. 什么是内存管理 移动设备的内存极其有限,每个app所能占用的内存是有限制的 当app所占用的内存较多时,系统会发出内存警告,这时得回收一些不需要再使用的内存空间.比如回收一些不需 ...
- php中的curl
/** * 请求接口返回内容 * @param string $url [请求的URL地址] * @param string $params [请求的参数] * @param int $ipost [ ...