题目描述: 源码: 需要注意的一点是输出是最简形式,需要去除小数的后导0,而调用stripTrailingZeros()函数后,数会以科学计数法输出,所以需要调用toPlainString(). import java.math.BigDecimal; import java.util.*; public class Main { //主函数 public static void main(String[] args) { BigDecimal a, b; Scanner cin = new S…
问题描述: 源码: 主要要注意输出格式. #include"iostream" #include"iomanip" #include"algorithm" #include"string" using namespace std; struct Person { string name; int count; int score; }; bool cmp(Person a, Person b) { if(a.count >…
题目描述: 源码: /**/ #include"iostream" using namespace std; int main() { int t, mod; long long n; cin>>t; for(int i = 0; i < t; i++) { cin>>n; mod = n % 10; if(mod == 0 || mod == 1 || mod == 5 || mod == 6) { cout<<mod<<endl…
问题描述: AC源码: 此题考察动态规划,解题思路:遍历(但有技巧),在于当前i各之和为负数时,直接选择以第i+1个为开头,在于当前i各之和为正数时,第i个可以不用作为开头(因为前i+1个之和一定大于第i+1个的值) #include"iostream" using namespace std; int main() { int t, n, start, end, sum, max, tmp; int a[100000]; scanf("%d", &t);…
题目描述: 源码: 需要注意,若使用cin,cout输入输出,会超时. #include"iostream" #include"memory.h" #define MAX 1000000 using namespace std; int index[MAX]; int main() { memset(index, -1, sizeof(index)); index[1] = 0; int sum = 0; for(int i = 2; i < MAX; i++…
问题描述: 源码: 经典问题——最近邻问题,标准解法 #include"iostream" #include"algorithm" #include"cmath" using namespace std; struct Point { double x; double y; }; Point S[100000];//不使用全局变量可能会超内存 bool cmpPointX(Point a, Point b) { return a.x > b…
问题描述: 源码: #include"iostream" #include"algorithm" using namespace std; bool cmp(int a, int b) { return a < b; } int main() { int n, result; int *p; while(true) { scanf("%d", &n); if(n == 0)break; p = new int[n]; for(int…
问题描述: 源码: import java.math.BigInteger; import java.util.*; public class Main { //主函数 public static void main(String[] args) { BigInteger a, b, zero = BigInteger.valueOf(0), f1, f2, fn; int count; Scanner cin = new Scanner(System.in); while(true) { a…
问题描述: 源码: import java.math.BigInteger; import java.util.*; public class Main { //主函数 public static void main(String[] args) { int n; BigInteger a, result, zero = BigInteger.valueOf(0); Scanner cin = new Scanner(System.in); n = cin.nextInt(); for(int…
问题描述: 源码: 考察对大数的计算,需要注意去除前导0与后导0. import java.math.BigDecimal; import java.util.*; public class Main { //主函数 public static void main(String[] args) { BigDecimal r; int n; String str; Scanner cin = new Scanner(System.in); while(cin.hasNext()) { r = ci…
题目描述: 源码: 运用Java大数求解. import java.math.BigInteger; import java.util.*; public class Main { //主函数 public static void main(String[] args) { int n, index; BigInteger f1, f2, fn; Scanner cin = new Scanner(System.in); n = cin.nextInt(); for(int i = 0; i <…
问题描述: 源码: /**/ #include"iostream" #include"string" using namespace std; void Print(string str, int end, int start) { for(int i = end; i >= start; i--)cout<<str[i]; } int main() { int n, start, end; string str; while(cin>>…
题目描述: 源码: #include"iostream" #include"cmath" using namespace std; #define PI 3.1415926 #define E 2.718281828459045 int main() { int n, num; double sum; cin>>n; for(int i = 0; i < n; i++) { cin>>num; // sum = 0; // for(in…
题目描述: 源码: /**/ #include"iostream" using namespace std; int MinComMultiple(int n, int m) { int x, y, tmp; long long s; s = (long long)n * (long long)m;//避免int的乘积越界 if(n > m) { tmp = n; n = m; m = tmp; } tmp = m % n; while(tmp != 0) { m = n; n…