题目链接:http://lightoj.com/volume_showproblem.php?problem=1149 Description You will be given two sets of integers. Let's call them set A and set B. Set A contains n elements and set B contains m elements. You have to remove k1 elements from set A and k2…
Pairs Forming LCM (LightOJ - 1236)[简单数论][质因数分解][算术基本定理](未完成) 标签: 入门讲座题解 数论 题目描述 Find the result of the following code: long long pairsFormLCM( int n ) { long long res = 0; for( int i = 1; i <= n; i++ ) for( int j = i; j <= n; j++ ) if( lcm(i, j) ==…
Sigma Function (LightOJ - 1336)[简单数论][算术基本定理][思维] 标签: 入门讲座题解 数论 题目描述 Sigma function is an interesting function in Number Theory. It is denoted by the Greek letter Sigma (σ). This function actually denotes the sum of all divisors of a number. For exam…
Goldbach`s Conjecture(LightOJ - 1259)[简单数论][筛法] 标签: 入门讲座题解 数论 题目描述 Goldbach's conjecture is one of the oldest unsolved problems in number theory and in all of mathematics. It states: Every even integer, greater than 2, can be expressed as the sum of…
http://www.lightoj.com/volume_showproblem.php?problem=1013 Yes, you are developing a 'Love calculator'. The software would be quite complex such that nobody could crack the exact behavior of the software. So, given two names your software will gene…
http://www.lightoj.com/volume_showproblem.php?problem=1011 You work in a company which organizes marriages. Marriages are not that easy to be made, so, the job is quite hard for you. The job gets more difficult when people come here and give their bi…
题解:隔一段数字存一个答案,在查询时,只要找到距离n最近而且小于n的存答案值,再把剩余的暴力跑一遍就可以. #include <bits/stdc++.h> using namespace std; const int N = 1e8 + 10; const int M = 2e6 + 10; double a[M]; void Init() { a[0] = 0.0; double ans = 1; for( int i = 2; i < N; i ++) { ans += 1.0 /…
You are x N grid. Each cell of the cave can contain any amount of gold. Initially you are . Now each turn you sided dice. If you get X in the dice after throwing, you add X to your position and collect all the gold from the new position. If your new…
You are in the world of mathematics to solve the great "Monkey Banana Problem". It states that, a monkey enters into a diamond shaped two dimensional array and can jump in any of the adjacent cells down from its current position (see figure). Wh…
题解:求一个数的次幂,然后输出前三位和后三位,后三位注意有前导0的情况. 后三位直接用快速幂取模求解. 前三位求得时候只需要稍微变形一下,可以把乘过的结果拆成用科学计数法,那么小数部分只有由前面决定,所以取前三位利用double来计算就可以了. #include <bits/stdc++.h> using namespace std; typedef long long ll; const int Mod = 1000; ll ppow(ll a, ll k) // 后三位 { ll ans…
题解:根据题目给的程序,就是计算给的这个序列,进行k次到n的循环,每个数需要加的次数是k*n^(k-1),所以快速幂取模,算计一下就可以了. #include <bits/stdc++.h> using namespace std; typedef long long ll; const int INF = 0x3f3f3f3f3f; long long pow_mod(ll a, ll k, ll mod) { ll ans = 1; while(k) { if(k%2) ans *= a;…
The first two consecutive numbers to have two distinct prime factors are: 14 = 2 7 15 = 3 5 The first three consecutive numbers to have three distinct prime factors are: 644 = 2² 7 23 645 = 3 5 43 646 = 2 17 19. Find the first four consecutiv…
1149 Dangerous Goods Packaging(25 分) When shipping goods with containers, we have to be careful not to pack some incompatible goods into the same container, or we might get ourselves in serious trouble. For example, oxidizing agent (氧化剂) must not be…
LightOJ1149 :Factors and Multiples 时间限制:2000MS 内存限制:32768KByte 64位IO格式:%lld & %llu 描述 You will be given two sets of integers. Let's call them set Aand set B. Set A contains n elements and set Bcontains m elements. You have to remove k1 elements…
Description 题目描述 While skimming his phone directory in 1982, Albert Wilansky, a mathematician of Lehigh University, noticed that the telephone number of his brother-in-law H. Smith had the following peculiar property: The sum of the digits of that nu…
Remainder Time Limit: 6000/3000 MS (Java/Others) Memory Limit: 65536/32768 K (Java/Others) Total Submission(s): 2255 Accepted Submission(s): 479 Problem Description Coco is a clever boy, who is good at mathematics. However, he is puzzled by a difficu…