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 ...
随机推荐
- VS2012 asp.net mvc 4 运行项目提示:"错误消息 401.2。: 未经授权: 服务器配置导致登录失败"
创建mvc4 应用程序发布,运行出错.出现未经授权: 服务器配置导致登录失败.请验证您是否有权基于您提供的凭,后来找得解决方法: 打开点站的web.confg文件,将: <authorizati ...
- jquery图片查看插件,支持旋转、放大、缩小、拖拽、缩略图(仿qq图片查看)
最近做了一个jquery图片查看的插件,目的是能精确查看图片的详情,插件支持图片旋转.放大.缩小.拖拽.缩略图显示,界面效果是按照window的qq查看图片功能写的,当然不尽相同. 具体功能: 1. ...
- ae IMap接口成员
使用IMap接口显示各种数据源的数据.IMap接口的成员ActiveGraphicsLayer:活动图形图层,如果没有将创建一个基本memory graphics layer.AddLayer:向地图 ...
- JavaScript学习10 JS数据类型、强制类型转换和对象属性
JavaScript学习10 JS数据类型.强制类型转换和对象属性 JavaScript数据类型 JavaScript中有五种原始数据类型:Undefined.Null.Boolean.Number以 ...
- iOS常用手势识别器
手势识别状态: typedef NS_ENUM(NSInteger, UIGestureRecognizerState) { // 没有触摸事件发生,所有手势识别的默认状态 UIGestureReco ...
- Android中将xml布局文件转化为View树的过程分析(下)-- LayoutInflater源码分析
在Android开发中为了inflate一个布局文件,大体有2种方式,如下所示: // 1. get a instance of LayoutInflater, then do whatever yo ...
- js 变量与值 连写
window.location.href="index.php?app=memberpmrecord&act=get_download&bname="+busine ...
- WPF之Binding深入探讨
原文:http://blog.csdn.net/fwj380891124/article/details/8107646 1,Data Binding在WPF中的地位 程序的本质是数据+算法.数据会在 ...
- 最新Internet Download Manager (IDMan) 6.25 Build 20 32位 64位注册破解补丁
0x00 IDMan介绍 Internet Download Manager提升你的下载速度最多达5倍,安排下载时程,或续传一半的软件.Internet Download Manager的续传功能可以 ...
- (转) 一步一步学习ASP.NET 5 (四)- ASP.NET MVC 6四大特性
转发:微软MVP 卢建晖 的文章,希望对大家有帮助.原文:http://blog.csdn.net/kinfey/article/details/44459625 编者语 : 昨晚写好的文章居然csd ...