当前位置: 首页 > news >正文

郑州网站免费制作网站页面下沉的特效代码

郑州网站免费制作,网站页面下沉的特效代码,安康电商网站建设,wordpress转换tpecho题意#xff1a; 有一个 nn 的矩阵#xff08;n 为奇数#xff09;#xff0c;每个矩阵单元有一个物品#xff0c;每次操作你可将一个单元里的一个物品移动到该单元周围的八个单元里#xff0c;问最后只有一个单元有物品的情况下#xff0c;最少要多少次操作#xff1…题意 有一个 n×n 的矩阵n 为奇数每个矩阵单元有一个物品每次操作你可将一个单元里的一个物品移动到该单元周围的八个单元里问最后只有一个单元有物品的情况下最少要多少次操作 题目 You are given a board of size n×n, where n is odd (not divisible by 2). Initially, each cell of the board contains one figure. In one move, you can select exactly one figure presented in some cell and move it to one of the cells sharing a side or a corner with the current cell, i.e. from the cell (i,j) you can move the figure to cells: (i−1,j−1); (i−1,j); (i−1,j1); (i,j−1); (i,j1); (i1,j−1); (i1,j); (i1,j1); Of course, you can not move figures to cells out of the board. It is allowed that after a move there will be several figures in one cell. Your task is to find the minimum number of moves needed to get all the figures into one cell (i.e. n2−1 cells should contain 0 figures and one cell should contain n2 figures). You have to answer t independent test cases. Input The first line of the input contains one integer t (1≤t≤200) — the number of test cases. Then t test cases follow. The only line of the test case contains one integer n (1≤n5⋅105) — the size of the board. It is guaranteed that n is odd (not divisible by 2). It is guaranteed that the sum of n over all test cases does not exceed 5⋅105 (∑n≤5⋅105). Output For each test case print the answer — the minimum number of moves needed to get all the figures into one cell. Example Input 3 1 5 499993 Output 0 40 41664916690999888 分析(1) 找规律。可以看到正方形的每一个“圈”到中心的最小距离都是一样的数一下就能发现规律。然后把整个正方形分成八个小三角形八条线或者直接按照圈来统计都行。 AC代码 #includestdio.h #includestring.h #includealgorithm using namespace std; typedef long long ll; int t; ll n,ans; int main() {scanf(%d,t);while(t--){ans0;scanf(%lld,n);for(ll i2; in/21; i)ans(i-2)*(i-1);ans*8;for(ll i1; in/21; i)ans(i-1)*8;printf(%lld\n,ans);}return 0; }分析二 我们可以将所有物品最终都汇聚到矩阵的中心的单元格那么以此为中心他周围的第一圈的单元格的物品只需要一步就可以第二圈就需要两步以此类推。   那么我们可以预处理出每一圈的单元格的数量乘以他对应的步数再求和即可。 AC代码 #include bits/stdc.h using namespace std; const int N 5e5 10; typedef long long ll; int f[N]; int main() {f[0] 0;for(int i 1; i N; i )f[i] f[i - 1] 8;int t;cin t;while(t --){ll n;cin n;n n * n - 1;ll ans 0;for(int i 1; ; i ){if(n f[i]){n - f[i];ans 1ll * i * f[i];}elsebreak;}cout ans endl;}return 0; }
http://www.zqtcl.cn/news/582913/

相关文章:

  • php企业网站多少钱图书馆网站建设建议
  • 企业网站建设综合实训学习体会个人网站空间申请
  • 企业小型网站要多少钱合肥城乡建设网站首页
  • 济南建站公司注意事项做钓鱼网站要什么工具
  • 网站建设数据录入创建网络公司
  • 行业网站建设报价摄影标志logo设计欣赏
  • 做reference的网站网站首页 模板
  • 微信php网站开发流程图做网站优化好的网络公司
  • 网站显示百度地图长沙制作网页的基本步骤
  • 免费做封面的网站哈尔滨网页制作要多少钱
  • html免费网页素材网站优化教程
  • 百度关键词网站排名优化软件seo服务 收费
  • 中英文切换网站网站建设的关键问题
  • 5款免费网站管理系统wordpress 本地
  • 企业网站制作公司盈利百度云搜索
  • 微云影视自助建站系统大理州建设局网站门户网
  • 构建网站需要会什么意思辽宁省朝阳网站建设
  • 网站建设捌金手指专业1公司域名邮箱注册
  • 建设工程协会网站建设工程合同属于专属管辖吗
  • 网站建设费可分摊几年电子商务网站建设基础
  • wordpress api 发贴北京网站优化seo
  • 青岛网站制作服务商wordpress红包
  • 网站响应式设计如何提高网站文章收录
  • 网站 橙色如何做自己网站的seo
  • 网上商城网站建设公司兰州网站制作公司怎么样
  • 网站的动态图怎么做的获取网站访客qq
  • 黑龙江网站建站建设知名品牌形象设计公司
  • 网站建设去哪可接单怎么做微信小程序平台
  • 做外贸重新设计网站兰州网站建设慕枫
  • 服装销售 网站建设论文搭建企业网站需要什么