如何为正规的网站建设公司设计专业的Flash网站导航条?
摘要:正规的网站建设专业公司,flash网站导航条怎么做,常熟企业网站建设价格,网站建设的合理建议视频链接 :希望下次秒懂的是算法题_哔哩哔哩_bilibiliP1094 [NOIP2007 普及组] 纪念品分组 原题链接 :[NOI
正规的网站建设专业公司,flash网站导航条怎么做,常熟企业网站建设价格,网站建设的合理建议视频链接 :
希望下次秒懂的是算法题_哔哩哔哩_bilibili
P1094 [NOIP2007 普及组] 纪念品分组
原题链接 :
[NOIP2007 普及组] 纪念品分组 - 洛谷 思路 :
排序 贪心 双指针首先先对输入进来的数组进行排序(由小到大)运用贪心的思想 : 前后结合,令l1,rn,若a[l]a[r]w…视频链接 :
希望下次秒懂的是算法题_哔哩哔哩_bilibili
P1094 [NOIP2007 普及组] 纪念品分组
原题链接 :
[NOIP2007 普及组] 纪念品分组 - 洛谷 思路 :
排序 贪心 双指针首先先对输入进来的数组进行排序(由小到大)运用贪心的思想 : 前后结合,令l1,rn,若a[l]a[r]w,那么a[l],a[r]可以成一组l,r--,ans,否则a[r]单独成一组,r--,ans;(这个求解过程用到双指针的思想);该贪心思路在做题的时候想可能是对的但是没有细究具体的思想请参考 : 题解 P1094 【纪念品分组】 - heidoudou 的博客 - 洛谷博客
代码 :
#includebits/stdc.h
#define IOS ios::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define endl \nusing namespace std;
typedef long long LL;
LL gcd(LL a,LL b){ return b0 ? a : gcd(b,a%b); }
LL lcm(LL a,LL b){ return a / gcd(a,b) * b ; }
bool is_prime(int x){if(x2) return false;
for(int i2;ix/i;i) if(x%i0) return false; return true;}
const int N 3e410,mod 1e97;
int n,w,a[N];
LL ans;inline void solve(){cinwn;for(int i1;in;i) cina[i];sort(a1,a1n);int l1,rn;while(lr){if(a[l]a[r]w){l; r--; ans ;}else {r--; ans ;}}coutans endl;
}int main()
{IOSint _;// cin _;_ 1; while(_ --) solve();return 0;
} P1102 A-B 数对
原题链接 :
https://www.luogu.com.cn/problem/P1102
思路 :
1.直接暴力,当然会tle了,hh( O(n^2) )
2.妙用map;(O(n))
3.用二分函数,upper_bound和lower_bound;对于a[i](a),其后满足 b-ac的连续区间长度可以用二分函数来求得(当然是对于排好序的数组) O(nlogn)
详细解答请看代码 :
代码 :
代码(暴力) : 直接暴力,当然会收获tle(3个),hhh
#includebits/stdc.h
#define IOS ios::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define endl \nusing namespace std;
typedef long long LL;
LL gcd(LL a,LL b){ return b0 ? a : gcd(b,a%b); }
LL lcm(LL a,LL b){ return a / gcd(a,b) * b ; }
bool is_prime(int x){if(x2) return false;
for(int i2;ix/i;i) if(x%i0) return false; return true;}
const int N 2e510,mod 1e97;
LL n,c,a[N];
LL ans;inline void solve(){cinnc;for(int i1;in;i) cina[i];for(int i1;in;i){for(int ji1;jn;j){if( (LL)(abs(a[i]-a[j])) c )ans ;}}cout ans endl;
}int main()
{IOSint _;// cin _;_ 1; while(_ --) solve();return 0;
}
代码(用map) :
// ma
