HDU1597 find the nth digit【模拟】
来源:互联网 发布:mac 压缩文件夹 编辑:程序博客网 时间:2024/05/16 18:45
问题链接:HDU1597 find the nth digit。
问题描述:参见上文。
问题分析:
计算还是模拟是一个值得思考的问题。
怎么算?找不到规律,找不到一个好的算法时,还是模拟吧。不过需要不是太花时间。
程序说明:
(略)
参考链接:(略)
AC的C++语言程序:
#include <iostream>using namespace std;int solve(int n){ // 模拟 int i = 1; while(n > i) { // 每次减去的i之和=前i项之和,当n>i则n在第i项中并且n已经被减去了之前i-1项的和 n -= i; i++; } n -= (n / 9) * 9; // 其中1-9是循环的,所以要重复减去9(不能为0,0的话改为9) n = (n ? n : 9); return n;}int main(){ int k, n; cin >> k; while(k--) { cin >> n; cout << solve(n) << endl; } return 0;}
阅读全文
1 0
- HDU1597 find the nth digit【模拟】
- HDU1597 find the nth digit
- HDU1597 find the nth digit
- hdu1597 find the nth digit(规律)
- HDU1597 - find the nth digit (找规律)
- hdu1597 find the nth digit(二分查找)
- find the nth digit
- find the nth digit
- find the nth digit
- find the nth digit
- find the nth digit
- find the nth digit
- find the nth digit
- find the nth digit
- find the nth digit
- 【HDU 1597】find the nth digit(模拟)
- hdu 1597 find the nth digit(模拟)
- find the nth digit(数论)
- 海报 demo
- jQuery取得select选中的值
- 第一个servlet
- 组合数学杂记(一)
- Implement Trie (Prefix Tree)
- HDU1597 find the nth digit【模拟】
- C++PrimerPlus第十一章学习笔记——使用类
- JavaScript中typeof的用法汇总(返回的是变量类型)
- 我的大一
- Recyclable Counter With Confinement (RCC)浅析
- Set up a flag
- 菜鸟学php扩展 之 hello world(一)
- 15 使用矩阵变换库进行图形变换
- 设计模式-装饰者模式学习笔记