“高教社杯”第三届福建省大学生程序设计竞赛
来源:互联网 发布:郑州淘宝诈骗 编辑:程序博客网 时间:2024/04/29 16:41
Link: 点击打开链接
Accept: 598 Submit: 1324
Time Limit: 1000 mSec Memory Limit : 32768 KB
Problem Description
You are given two positive integers A and B in Base C. For the equation:
We know there always existing many non-negative pairs (k, d) that satisfy the equation above. Now in this problem, we want to maximize k.
For example, A="123" and B="100", C=10. So both A and B are in Base 10. Then we have:
(1) A=0*B+123
(2) A=1*B+23
As we want to maximize k, we finally get one solution: (1, 23)
The range of C is between 2 and 16, and we use 'a', 'b', 'c', 'd', 'e', 'f' to represent 10, 11, 12, 13, 14, 15, respectively.
Input
The first line of the input contains an integer T (T≤10), indicating the number of test cases.
Then T cases, for any case, only 3 positive integers A, B and C (2≤C≤16) in a single line. You can assume that in Base 10, both A and B is less than 2^31.
Output
Sample Input
Sample Output
Source
“高教社杯”第三届福建省大学生程序设计竞赛java进制转换:
import java.text.*;import java.util.*;import java.math.*;public class Main{public static void main(String args[]){Scanner cin=new Scanner(System.in);BigInteger b1,sum1,sum2,x,t,d,ans1,ans2;int cas,tt,w,k;String s1,s2;char c;tt=cin.nextInt();for(cas=1;cas<=tt;cas++){s1=cin.next();s2=cin.next();b1=cin.nextBigInteger();sum1=BigInteger.valueOf(0);sum2=BigInteger.valueOf(0);t=BigInteger.ONE;//System.out.println(s1+s2+b1);for(int i=s1.length()-1;i>=0;i--){c=s1.charAt(i);if(c>='0'&&c<='9')w=c-'0';elsew=c-'a'+10;sum1=sum1.add(BigInteger.valueOf(w).multiply(t));t=t.multiply(b1);}//System.out.println(sum1.toString());t=BigInteger.ONE;for(int i = s2.length()-1;i>=0;i--){c=s2.charAt(i);if(c>='0'&&c<='9')w=c-'0';elsew=c-'a'+10;sum2=sum2.add(BigInteger.valueOf(w).multiply(t));t=t.multiply(b1);}//System.out.println(sum2.toString());ans1=BigInteger.ZERO;ans2=sum2;for(k=0;;k++)//注意:for循环里面变量不能用大数表示!!!即k不能定义为大数!!!{d=sum1.subtract(BigInteger.valueOf(k).multiply(sum2));if(d.compareTo(BigInteger.ZERO)<0)break;ans1=BigInteger.valueOf(k);ans2=d;}System.out.println("("+ans1.toString()+","+ans2.toString()+")");}}}
Accept: 594 Submit: 668
Time Limit: 1000 mSec Memory Limit : 32768 KB
Problem Description
In this problem, we have f(n,x)=Floor[n/x]. Here Floor[x] is the biggest integer such that no larger than x. For example, Floor[1.1]=Floor[1.9]=1, Floor[2.0]=2.
You are given 3 positive integers n, L and R. Print the result of f(n,L)+f(n,L+1)+...+f(n,R), please.
Input
The first line of the input contains an integer T (T≤100), indicating the number of test cases.
Then T cases, for any case, only 3 integers n, L and R (1≤n, L, R≤10,000, L≤R).
Output
Sample Input
Sample Output
Source
“高教社杯”第三届福建省大学生程序设计竞赛import java.text.*;import java.util.*;import java.math.*;public class Main{public static void main(String args[]){Scanner cin=new Scanner(System.in);BigInteger b1,x,t,d,ans;int cas,tt,w,k,l,r;String s1,s2;char c;tt=cin.nextInt();for(cas=1;cas<=tt;cas++){//s1=cin.next();//s2=cin.next();b1=cin.nextBigInteger();l=cin.nextInt();r=cin.nextInt();ans=BigInteger.ZERO;for(int i=l;i<=r;i++){ans=ans.add(b1.divide(BigInteger.valueOf(i)));}System.out.println(ans.toString());}}}
- “高教社杯”第三届福建省大学生程序设计竞赛
- “高教社杯”第三届福建省大学生程序设计竞赛
- "高教社杯"第三届福建省大学生程序设计竞赛
- “高教社杯”第三届福建省大学生程序设计竞赛
- 第四届福建省大学生程序设计竞赛
- 第六届福建省大学生程序设计竞赛
- 2016 第七届福建省大学生程序设计竞赛
- 第八届福建省大学生程序设计竞赛
- FZU Problem 2102 Solve equation 第三届福建省大学生程序设计竞赛
- 第四届(2013年十月)福建省大学生程序设计竞赛
- 第六届福建省大学生程序设计竞赛 Problem J RunningMan【数学】
- 第六届福建省大学生程序设计竞赛 Super Mobile Charger
- 第六届福建省大学生程序设计竞赛 Common Tangents
- 第六届福建省大学生程序设计竞赛(FZU2212—FZU2221)
- 福建省第七届大学生程序设计竞赛 ---- 赛后总结
- Common Tangents【第六届福建省大学生程序设计竞赛-重现赛】
- RunningMan【第六届福建省大学生程序设计竞赛-重现赛】
- FOJ 2213 Common Tangents 【第六届福建省大学生程序设计竞赛】
- oracle中表空间,块,用户的关系
- Mac OS X Mavericks 配置 Apache+Mysql+PHP 详细教程
- 结构体
- Android数据的四种存储方式SharedPreferences、SQLite、Content Provider和File (三) —— SharePreferences
- HDU 3466 01背包变形
- “高教社杯”第三届福建省大学生程序设计竞赛
- /dev/shm和swap区别与联系
- PAT 1021. Deepest Root 不狗血,无剧情(关于函数的堆的大小限制)
- Flex学习笔记(三)——字符串的操作(String)
- Mac OS X Yosemite 10.10 配置 Apache+PHP 教程注意事项
- ubuntu 12.04 eclipse 报 program g++ not found in path
- SORM的CURD以及事务
- 《大话操作系统——做坚实的工程实践派》(7)
- Android数据的四种存储方式SharedPreferences、SQLite、Content Provider和File (四) —— ContentProvider