1:求两个和数x,y,使得x+y = n。刚开始没看懂题目意思就开始敲。。。结果可想而知。再次细心读题才发现。果然要做题必须要先理解题意。(才得了207.52)
bool is_prime(int x){
if(x == 2) return true;
for(int i = 2; i <= sqrt(x); i ++)
if(x % i == 0) return false;
return true;
}
class SilverbachConjecture{
public :
vector <int> solve(int n){
vector<int> a;
int x, y;
for(int i = 2; i <= n; i ++){
x = i;
y = n - i;
if(!is_prime(x) && !is_prime(y) )
break;
}
a.push_back(x);
a.push_back(y);
return a;
}
};
2:简单模拟题。题目大意:第i天可以产morning[i]个东东,第i天可以卖customers[i]东东,如果customer[i] < morning[i]那么只能卖customers[i]个东东,余下的第二天来卖但是第stale_limit天前的东东会腐烂,所以要扔掉,不能卖。
(翻译有点不好,但是意思就是这样O(∩_∩)O哈哈~)(~~~~(>_<)~~~~ ,这题才的247.94。还以为可以涨为绿呢)
class SlimeXSlimonadeTycoon{
public :
int sell(vector <int> morning, vector <int> customers, int stale_limit){
int n = morning.size();
int sum = 0;
for(int i = 0; i < n; i ++){
int s = i-stale_limit+1 >= 0 ? i-stale_limit+1 : 0;
//cout << s << endl;
for(int j = s; j <= i; j ++){
int temp = customers[i] > morning[j] ? morning[j] : customers[i];
customers[i] -= temp;
morning[j] = morning[j] - temp;
sum += temp;
}
}
//cout << sum << endl;
return sum;
}
};
感觉要上一个台阶,真的好难咦,不过努力吧,突破这个瓶颈,向更高方向前进。。好好打基础。。
3:先暴力枚举要切的点,然后统计一下就行了。但是这样对于10^9的数据暴力的话绝壁超时。然后你会发现这些数刚好是n-phi(n);想到这点后就容易解决了。