PAT 天梯赛 L1-046. 整除光棍 【模拟除法】
题目链接
https://www.patest.cn/contests/gplt/L1-046
思路
用同余定理以及模拟除法。
AC代码
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <cmath>
#include <deque>
#include <vector>
#include <queue>
#include <string>
#include <cstring>
#include <map>
#include <stack>
#include <set>
#include <cstdlib>
#include <ctype.h>
#include <numeric>
#include <sstream>
using namespace std;
typedef long long LL;
const double PI = 3.14159265358979323846264338327;
const double E = 2.718281828459;
const double eps = 1e-6;
const int MAXN = 0x3f3f3f3f;
const int MINN = 0xc0c0c0c0;
const int maxn = 1e5 + 5;
const int MOD = 1e9 + 7;
int main()
{
int n;
cin >> n;
LL ans;
int len = 1;
for (ans = 1; ans < n; ans = ans * 10 + 1)
len++;
while (1)
{
if (ans % n == 0)
{
cout << ans / n;
break;
}
else
{
cout << ans / n;
len++;
ans %= n;
ans = ans * 10 + 1;
}
}
cout << " " << len << endl;
}
PAT 天梯赛 L1-046. 整除光棍 【模拟除法】的更多相关文章
- 【PTA 天梯赛】L1-046 整除光棍(除法模拟)
这里所谓的“光棍”,并不是指单身汪啦~ 说的是全部由1组成的数字,比如1.11.111.1111等.传说任何一个光棍都能被一个不以5结尾的奇数整除.比如,111111就可以被13整除. 现在,你的程序 ...
- PAT L1 - 046 整除光棍
https://pintia.cn/problem-sets/994805046380707840/problems/994805084284633088 这里所谓的“光棍”,并不是指单身汪啦~ 说的 ...
- PTA 天梯赛 L1
L1-002 打印沙漏 细节:就是在 (i>j&&i+j<r+1) 这个区间里才有空格,然后就是 for 循环 for(r=1; ;r+=2) 条件不满足之后还会再 ...
- PAT天梯赛 L1-049 天梯赛座位分配
题目链接:点击打开链接 天梯赛每年有大量参赛队员,要保证同一所学校的所有队员都不能相邻,分配座位就成为一件比较麻烦的事情.为此我们制定如下策略:假设某赛场有 N 所学校参赛,第 i 所学校有 M[i] ...
- PAT天梯赛L3-007 天梯地图
题目链接:点击打开链接 本题要求你实现一个天梯赛专属在线地图,队员输入自己学校所在地和赛场地点后,该地图应该推荐两条路线:一条是最快到达路线:一条是最短距离的路线.题目保证对任意的查询请求,地图上都至 ...
- PAT天梯赛练习题——L3-007. 天梯地图(多边权SPFA)
L3-007. 天梯地图 时间限制 300 ms 内存限制 65536 kB 代码长度限制 8000 B 判题程序 Standard 作者 陈越 本题要求你实现一个天梯赛专属在线地图,队员输入自己学校 ...
- L1-046 整除光棍 大数除法
L1-046 整除光棍(20 分) 这里所谓的"光棍",并不是指单身汪啦~ 说的是全部由1组成的数字,比如1.11.111.1111等.传说任何一个光棍都能被一个不以5结尾的奇数整 ...
- PAT 天梯赛 L1-027. 出租 【模拟】
题目链接 https://www.patest.cn/contests/gplt/L1-027 题意 给出一串电话号码,找出其中不同数字的个数,并且按递减顺序排列,然后 有一个index 数组,指出每 ...
- PAT 天梯赛 L1-009. N个数求和 【模拟】
题目链接 https://www.patest.cn/contests/gplt/L1-009 思路 每一步每一步 往上加,但是要考虑 溢出,所以用 LONG LONG 而且 每一步 都要约分 才能保 ...
随机推荐
- Python 2.7 中使用 Print 方法
print ("test",file=name)类似的方法在python 2中需要先引入 __future__才可使用 import __futhure__ import prin ...
- LINUX内核升级-更新网卡驱动
因项目需要,将当前内核(2.6.32-220.el6.x86_64)升级到目标内核(2.6.33-110.el6.x86_64),但是编译的目标 内核(2.6.33-110.el6.x86_64)的对 ...
- linux 免密登录
ssh-keygen -t rsa -P "" ssh-copy-id -i ~/.ssh/id_rsa.pub root@服务器地址
- 整合Thinkphp数据库基本操作CURD,界面datagrid采用EasyUi的Demo
1 <?php 2 class CurdAction extends Action{ 3 public function del($id){ 4 ...
- jQuery 尺寸 方法
jQuery 提供多个处理尺寸的重要方法: width() height() innerWidth() innerHeight() outerWidth() outerHeight()
- ActiveMQ部署步骤和后台管理网站Service Unavailable问题解决笔记
最近部署ActiveMQ的时候,发现有的服务器可以打开后台管理网址,有的服务器无法打开,Jetty报503 Service Unavailable. 搞了很久终于发现了问题,现将部署和解决过程做笔记如 ...
- billboard Shader待研究下
Shader "Tut/Project/Billboard_1" { Properties { _MainTex ("Base (RGB)", 2D) = &q ...
- poj 1470(LCA)
题目链接:http://poj.org/problem?id=1470 思路:题目的意思很简单,就是求树中每个节点作为某两个节点的最近公共祖先的次数,这里我们可以用sum数组来保存,然后就是从根节点开 ...
- try git
Git allows groups of people to work on the same documents (often code) at the same time, and without ...
- Android--去除EditText边框,加入下划线
<span style="font-family: Arial, Helvetica, sans-serif;"><?xml version="1.0& ...