ACM STEPS——Chapter Two——Section One
数学题小关,做得很悲剧,有几道题要查数学书。。。
记下几道有价值的题吧
The area(hdoj 1071)
http://acm.hdu.edu.cn/showproblem.php?pid=1071
直线方程易求,曲线方程要推公式。。。设y=a*x^2+b*x+c,则顶点坐标为(-b/(2a),4ac-b^2)/(4a)),又从题目中已知顶点坐标为(x1,y1),以及另一点(x2,y2),则有
y2=a*x2*x2+b*x2+c
y1=a*x1*x1+b*x1+c
x1=-b/(2*a)
所以a=(y2-y1)/((x2-x1)*(x2-x1))
求出a后,剩下的b和c就没问题,而面积直接用定积分的定义搞定
AC CODE:
#include<cstdio>
#include<cstring>
#include<iostream>
#include<algorithm>
int MIN(int a,int b) { if( a<b )
return a; else return b; }
int MAX(int a,int b) { if( a>b )
return a; else return b; }
#define CLR(NAME,VALUE) memset(NAME,VALUE,sizeof(NAME))
using namespace std;
const int N=10000;
int main() {
int ca,i;
double
x1,y1,x2,y2,x3,y3,m,n,res,dtmp,x,a,b,c;
cin>>ca;
while( ca-- ) {
cin>>x1>>y1>>x2>>y2>>x3>>y3;
//y=m*x+n
m=(y2-y3)/(x2-x3);
n=y3-m*x3;
//y=a*x^2+b*x+c
a=(y2-y1)/((x2-x1)*(x2-x1));
b=-2*a*x1;
c=y1-a*x1*x1-b*x1;
x=x2;
res=0;
dtmp=(x3-x2)/N;
for(i=0;i<N;++i) {
x+=dtmp;
res+=dtmp*(a*x*x+b*x+c-m*x-n);
}
printf("%.2lf\n",res);
}
return 0;
}
找新朋友(hdoj 1286)
http://acm.hdu.edu.cn/showproblem.php?pid=1286
定义:设φ(m)表示不超过m,而和m互质的正整数的个数,则φ(m)称为欧拉函数
计算公式:若a=(p1^a1)*(p2^a2)…(pn^an) 是 a 的标准分解式,则
φ(a)= a*(1-1/p1)*(1-1/p2)…(1-1/pn)
//pi是质数,且是a的因数
然后先求出范围内的质数,代公式,搞定
#include<cstdio>
#include<cstring>
#include<iostream>
#include<algorithm>
int MIN(int a,int b) { if( a<b
) return a; else return b;
}
int MAX(int a,int b) { if( a>b )
return a; else return b; }
#define CLR(NAME,VALUE) memset(NAME,VALUE,sizeof(NAME))
using namespace std;
const int N=32768+2;
bool notPrim[N];
int main() {
int ca,n,i,j;
for(i=2;i<N;++i) {
if( !notPrim[i] ) {
for(j=i;i*j<N;++j) {
notPrim[i*j]=true;
}
}
}
cin>>ca;
while( ca-- ) {
cin>>n;
double res=n;
for(i=2;i<=n;++i) {
if(
!notPrim[i] && n%i==0 ) {
res=res*(1-1.0/i);
}
}
cout<<res<<endl;
}
return 0;
}
整数对(hdoj 1271)
http://acm.hdu.edu.cn/showproblem.php?pid=1271
这个其实可以当作是一类题来处理,即去掉数字中一位数后,再OOXX的题
假设A是原来的数,B是去掉A中一位数后的数,N=A+B
A=a*10^(k+1)+b*10^k+c //假设要去掉的是第k+1位数,而b就是该位的数字,a是b之前的数字,c是b之后的数字
B=a*10^k+c
N=a*11*10^k+b*10^k+2*c
从枚举10^k入手,将第三式右边除以10^k后,得到a*11+b,那么要得到a,只需再除以11,而要b,则对11取余。但这只是2*c无进位的情况,当有进位时,要将得到的b的值再减1。再下来就是验证c是否存在就可以了。
#include<set>
#include<cstdio>
#include<cstring>
#include<iostream>
#include<algorithm>
int MIN(int a,int b) { if( a<b
) return a; else return b;
}
int MAX(int a,int b) { if( a>b )
return a; else return b; }
#define CLR(NAME,VALUE) memset(NAME,VALUE,sizeof(NAME))
using namespace std;
int main() {
int n,i,k,a,b,c;
while( cin>>n,n )
{
set<int> con;
for(k=1;k<=n;k*=10) {
a=(n/k)/11;
//无进位
b=(n/k) %
11;
if(
b<10 && (a!=0||b!=0)
) {
c=n-a*11*k-b*k;
if( c%2==0 ) {
con.insert(a*k*10+b*k+c/2);
}
}
//有进位
b=(n/k) %
11-1;
if(
b>=0 && (a!=0||b!=0)
) {
c=n-a*11*k-b*k;
if( c%2==0 ) {
con.insert(a*10*k+b*k+c/2);
}
}
}
if( con.size()==0 ) {
printf("No
solution.\n");
continue;
}
i=0;
for(set<int>::iterator
index=con.begin();index!=con.end();++index,++i) {
printf("%d%c",*index,i==con.size()-1?'\n':' ');
}
}
return 0;
}
Leftmost Digit(HDOJ
1060)
http://acm.hdu.edu.cn/showproblem.php?pid=1060
N^N=a*10^k
//0<a<1,k为N^N的位数
两边取以10为底的对数
N*log10(N)=log10(a)+k
k=log10(N^N)=N*log10(N)取整
则log10(a)=N*log10(N)-取整(N*log10(N))
#include<cmath>
#include<cstdio>
#include<cstring>
#include<iostream>
#include<algorithm>
int MIN(int a,int b) { if( a<b
) return a; else return b;
}
int MAX(int a,int b) { if( a>b )
return a; else return b; }
#define CLR(NAME,VALUE) memset(NAME,VALUE,sizeof(NAME))
using namespace std;
int main() {
int ca,n;
double x;
cin>>ca;
while( ca-- ) {
cin>>n;
x=n*log10((double)n);
x=x-(__int64)x;
cout<<(int)pow(10.0,x)<<endl;
}
return 0;
}
ACM STEPS——Chapter Two——Section One的更多相关文章
- MathType 插入定义的chapter and section break后无法隐藏
每一章标题后面插入一个“Next Section Break”,这样定稿后各章文件组合为总文件后,方程编号会自动递增,如果已经插入了默认的“Equation Chapter 1 Section 1”, ...
- Word中去除/删除/删掉Equation Chapter (Next) Section 1
实际问题如图显示 Equation Chapter (Next) Section 1 . 具体操作步骤如下: 1.Word的"格式"菜单--"样式和格式",出现 ...
- mathtype 章节号 Equation Chapter 1 Section 1 的去除
mathtype 章节号 Equation Chapter 1 Section 1 的去除 转:http://hi.baidu.com/17ximm/blog/item/2882413e92fc96c ...
- HDOJ acm steps 3.1.1
(都是递推求值,呵呵,好开心- - ) 今天又是在自习室通宵(文明玩的停不下来了) 游戏玩完想想该水题了,于是打开了HDOJ的ACM STEPS(这是个好东西,就像他的名字,一步步来的) 2.3.x貌 ...
- hdu ACM Steps Section 1 花式A+B 输入输出格式
acm与oi很大的一个不同就是在输入格式上.oi往往是单组数据,而acm往往是多组数据,而且题目对数据格式往往各有要求,这8道a+b(吐槽..)涉及到了大量的常用的输入输出格式.https://wen ...
- hdu acm steps Big Event in HDU
上网搜了一下这道题的解法,主要有两个方法,一种是采用母函数的方法,一种是采用0/1背包的方法. 先说一下母函数,即生成函数,做个比喻,母函数就是一个多项式前面的系数的一个整体的集合,而子函数就是这个多 ...
- ACM思维题训练 Section A
题目地址: 选题为入门的Codeforce div2/div1的C题和D题. 题解: A:CF思维联系–CodeForces -214C (拓扑排序+思维+贪心) B:CF–思维练习-- CodeFo ...
- ACM Steps 2.1.8
小数化分数2 Time Limit: 1000/1000 MS (Java/Others) Memory Limit: 32768/32768 K (Java/Others) Total Sub ...
- ACM Steps 2.1.7
Leftmost Digit Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 65536/32768 K (Java/Others) T ...
随机推荐
- hadoop发行版本
Azure HDInsight Azure HDInsight is Microsoft's distribution of Hadoop. The Azure HDInsight ecosystem ...
- logging的使用
[logging的使用] import logging # 创建一个logger logger = logging.getLogger('mylogger') logger.setLevel(logg ...
- linux 用户管理(3)----查看用户登录时间以及命令历史
1.查看当前登录用户信息 who命令: who缺省输出包括用户名.终端类型.登陆日期以及远程主机. who /var/log/wtmp 可以查看自从wtmp文件创建以来的每一次登陆情况 (1)-b:查 ...
- angluarjs ng-repeat 行号
参考 https://zhidao.baidu.com/question/1882914672116911828.html $index
- 兼容IE7、IE8、IE9的input type="number"插件
IE11版本好像才兼容input type="number",但是现在Win7版本操作系统下,很多人的IE版本都是IE7/8/9,所以为了体验就自己写了一个小插件,支持设置最大值. ...
- 2014年可用的TRACKER服务器大全
udp://tracker.openbittorrent.com:80/announceudp://tracker.publicbt.com:80/announcehttp://pubt.net:27 ...
- hdoj1043 Eight(逆向BFS+打表+康拓展开)
题目链接:http://acm.hdu.edu.cn/showproblem.php?pid=1043 思路: 由于自己对康拓展开用的太少,看到这个题没想到康拓展开,最开始打算直接转换为数字,但太占内 ...
- 兼容多浏览器的网页复制插件(ZeroClipboard)
前言: 常规利用JS编写的网页复制功能是最简单的方法,但是只对IE有效,无法做到兼容其它浏览器,对其他浏览器也就只能弹窗提示用户手动复制了. <script type="text/ja ...
- mybatis遍历array数组与集合、json
遍历数组: int saveOptions(@Param("items")String[] items, @Param("questionId")int que ...
- (重要)LRU cache
[抄题]: [思维问题]: 需要从任何位置访问某数字有没有(重要 ),返回其位置(不重要),所以用hashmap. 需要从任何位置删除,用linkedlist.最终二者结合,用linked hashm ...