题目链接:

  http://acm.xmu.edu.cn/JudgeOnline/problem.php?id=1044

题目大意

  求首项为0,公比为x的等差数列组成的数字条的第y位数字是几。(x,y<=2*109)

题目思路:

  【数学】【模拟】

  万万没想到这道题暴力我就过了。

  0ms是计算在x为公差的情况下每位数会有几个数列中的数(例如x=3,369121518...一位数就有3个)

  直接计算第y个数字是包含在几位数的等差数列中,是第几个数字。

暴力:

 //
//by coolxxx
//
#include<iostream>
#include<algorithm>
#include<string>
#include<iomanip>
#include<memory.h>
#include<time.h>
#include<stdio.h>
#include<stdlib.h>
#include<string.h>
//#include<stdbool.h>
#include<math.h>
#define min(a,b) ((a)<(b)?(a):(b))
#define max(a,b) ((a)>(b)?(a):(b))
#define abs(a) ((a)>0?(a):(-(a)))
#define lowbit(a) (a&(-a))
#define sqr(a) ((a)*(a))
#define swap(a,b) ((a)^=(b),(b)^=(a),(a)^=(b))
#define eps (1e-8)
#define J 10000000
#define MAX 0x7f7f7f7f
#define PI 3.1415926535897
#define N 104
using namespace std;
typedef long long LL;
int cas,cass;
int n,m,lll,ans;
LL sum;
LL e[N];
int get(LL x)
{
int i=;
while(x>=e[i+])i++;
return i;
}
int main()
{
#ifndef ONLINE_JUDGE
// freopen("1.txt","r",stdin);
// freopen("2.txt","w",stdout);
#endif
int i,j;
// for(scanf("%d",&cas);cas;cas--)
// for(scanf("%d",&cas),cass=1;cass<=cas;cass++)
// while(~scanf("%s",s))
e[]=,e[]=;
for(i=;i<=;i++)e[i]=e[i-]*;
while(~scanf("%d",&n))
{
scanf("%d",&m);
i=;
j=get(n);
for(sum=n;i<m;sum+=n,i+=j)
{
if(sum>=e[j+])j++;
}
sum-=n;
if(i==m)printf("%d\n",sum%);
else
{
i=m-(i-j);
printf("%d\n",sum/e[j-i+]%);
}
}
return ;
}
/*
// //
*/

千万不要点

数学:

 //
//by coolxxx
//
#include<iostream>
#include<algorithm>
#include<string>
#include<iomanip>
#include<memory.h>
#include<time.h>
#include<stdio.h>
#include<stdlib.h>
#include<string.h>
//#include<stdbool.h>
#include<math.h>
#define min(a,b) ((a)<(b)?(a):(b))
#define max(a,b) ((a)>(b)?(a):(b))
#define abs(a) ((a)>0?(a):(-(a)))
#define lowbit(a) (a&(-a))
#define sqr(a) ((a)*(a))
#define swap(a,b) ((a)^=(b),(b)^=(a),(a)^=(b))
#define eps (1e-8)
#define J 10000000
#define MAX 0x7f7f7f7f
#define PI 3.1415926535897
#define N 104
using namespace std;
typedef long long LL;
LL cas,cass;
LL n,m,lll,ans;
LL s[];
LL x;
int main()
{
#ifndef ONLINE_JUDGE
// freopen("1.txt","r",stdin);
// freopen("2.txt","w",stdout);
#endif
LL i,j;
// for(scanf("%d",&cas);cas;cas--)
// for(scanf("%d",&cas),cass=1;cass<=cas;cass++)
// while(~scanf("%s",s))
while(~scanf("%lld",&n))
{
scanf("%lld",&m);
if(n==)
{
puts("");
continue;
}
for(i=,x=;i<;i++,x*=)
s[i]=(x-)/n;
for(i=;i>;i--)
s[i]-=s[i-];
for(i=,x=;i< && m>=s[i]*i;i++)
m-=s[i]*i,x+=s[i]*n;
x+=m/i*n;
if(m%i==)
{
printf("%d\n",x%);
continue;
}
x+=n;
i-=m%i;
while(i--)x/=;
printf("%d\n",x%);
}
return ;
}
/*
// //
*/

千万不要点

【数学】【模拟】XMU 1044 伪伪随机数产生器的更多相关文章

  1. 【数学】XMU 1593 找数字

    题目链接: http://acm.xmu.edu.cn/JudgeOnline/problem.php?id=1593 题目大意: T组数据,n个数,只有一种出现q次,其余的出现p次.(1<=T ...

  2. 【数学】XMU 1597 GCD

    题目链接: http://acm.xmu.edu.cn/JudgeOnline/problem.php?id=1597 题目大意: 求(am-bm, an-bn),结果取模1000000007,a,b ...

  3. 2017 Multi-University Training Contest - Team 9 1004&&HDU 6164 Dying Light【数学+模拟】

    Dying Light Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 131072/131072 K (Java/Others)Tot ...

  4. zzulioj--1825-- 会长爱数学(模拟)

    1825: 会长爱数学 Time Limit: 1 Sec  Memory Limit: 128 MB Submit: 6  Solved: 2 SubmitStatusWeb Board Descr ...

  5. 数学&模拟:随机化-矩阵随机化

    BZOJ2396 给出三个行数和列数均为N的矩阵A.B.C,判断A*B=C是否成立 随机生成一个N乘1的矩阵R 然后判断A*B*R是否等于C*R,而前者相当于A*(B*R) 与后者一样都可以在O(N2 ...

  6. 2017ACM暑期多校联合训练 - Team 2 1008 HDU 6052 To my boyfriend (数学 模拟)

    题目链接 Problem Description Dear Liao I never forget the moment I met with you. You carefully asked me: ...

  7. CF 990A. Commentary Boxes【数学/模拟】

    [链接]:CF [题意]:对于一个数n,每次加一的代价是a,每次减一的代价是b,求被m整除时的最小代价. [分析]:分情况讨论,自己多举几个栗子. [代码]: #include<cstdio&g ...

  8. CF 450E Jzzhu and Apples 数学+模拟

    E. Jzzhu and Apples time limit per test 1 second memory limit per test 256 megabytes input standard ...

  9. [CSP-S模拟测试]:砍树(数学+模拟)

    题目传送门(内部题1) 输入格式 第一行两个整数$n$,$k$,代表树苗的数量和最大看书的总长度.第二行n个整数$a_i$,代表林先森希望每棵树苗的最终高度. 输出格式 一行一个整数,代表最大可能的d ...

随机推荐

  1. intent和intentfilter

    intent 和intent Filters startActivity()的机制 用到了IBinder ipc 用到了进程间通讯机制 activity有四种LaunchMode 当startActi ...

  2. getconf 取系统配制 --CPU

    cpu 缓存:getconf -a LEVEL1_ICACHE_SIZE LEVEL1_ICACHE_ASSOC LEVEL1_ICACHE_LINESIZE LEVEL1_DCACHE_SIZE L ...

  3. Android ActionBar(转)

    本文内容 关于 ActionBar 必要条件 项目结构 环境 演示一:Action Bar 显示隐藏 演示二:Action Item 显示菜单选项 演示三:Action Home 启用“返回/向上”程 ...

  4. LeanCloud使用入门(android)

    LeanCloud算是一个简单易用的云服务器,其中包含了强大的数据库支持,我们只需要将此服务器应用到本地的代码即可实现后台的存储与交互. 那么,如何简单实现本地代码和LeanCloud服务器的交互呢? ...

  5. python栈的实现(入栈,出栈)

    #coding=utf-8 class Stack(): def __init__(st,size):#栈的初始化 st.stack=[]; st.size=size; st.top=-1 def p ...

  6. spring-data-mongodb查询结果返回指定字段

        方法1 DBObject dbObject = new BasicDBObject(); dbObject.put("status", 1); DBObject field ...

  7. oracle问题 《经由直接路径由 EXPORT:V10.02.01 创建的导出文件 IMP-00013: 只有 DBA 才能导入由其他 DBA 导出的文件》

    问题:  经由直接路径由 EXPORT:V10.02.01 创建的导出文件 : 只有 DBA 才能导入由其他 DBA 导出的文件 解决方法:用sys 登录,给当前用户授权,授权语句:grant dba ...

  8. SystemConfig.getPropertyValue("test");配置文件已经加了test=abc,但是取得时候空字符串

    1.定位tomcat中System.properties是否配置了,发现配置了 2.定位myeclipse中修改的tomcat是不是自己配置的tomcat.发现是 3.定位如下位置配置是否读取我先在用 ...

  9. iOS开发UI篇——九宫格坐标计算

    一.要求 完成下面的布局 二.分析 寻找左边的规律,每一个uiview的x坐标和y坐标. 三.实现思路 (1)明确每一块用得是什么view (2)明确每个view之间的父子关系,每个视图都只有一个父视 ...

  10. MySQL 序列使用

    MySQL 序列使用 MySQL序列是一组整数:1, 2, 3, ...,由于一张数据表只能有一个字段自增主键, 如果你想实现其他字段也实现自动增加,就可以使用MySQL序列来实现. 本章我们将介绍如 ...