I love cube

I love cube

Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 524288/524288 K (Java/Others)
Total Submission(s): 2805 Accepted Submission(s): 770


 

Problem Description
Give you a cube with a side length of n-1. Find the number of equilateral triangles with three points on the cube point. Each side must be parallel to a certain surface of Oxy, Oxz, Oyz. Now you need to count how many such triangles there are.Each point can only be on the boundary or inner point of the cube, and the three coordinates x, y, and z of each point must be integers.
 

Input
The first line contains an integer T(T<=1e5) . Then T test cases follow.

Each test case contains a single Integer n(0<=n<=1e18).

If n=0, output 0
 

Output
For each case, print an integer, which is the answer modulo 109+7
 

Sample Input
 
 
2 1 2
 

Sample Output
 
 
8
思路 :由题意知,要求等边三角形的数量,每个立方体有八个顶点,所以有8个等边三角形。等价于求立方体的数量。

又因为n的范围为0- 1e18

所以需要用到模板:a*b%p

 ll mul(ll a,ll b,ll p){
    ll ans=0;
    while(b){
        if(b&1) ans=(ans+a)%p;
        a=a*2%p;
        b>>=1;
    }
    return ans;
}

代码如下:

#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const int mod=1e9+7;
ll mul(ll a,ll b){
    ll ans=0;
    while(b){
        if(b&1) ans=(ans+a)%mod;
        a=a*2%mod;
        b>>=1;
    }
    return ans;
}
int main(){
    int t,n;
    cin>>t;
    while(t--){
        cin>>n;
        if(n==0||n==1) cout<<"0"<<endl;//特判
        else{
            n--;
            cout<<mul(n,n)%mod*mul(n+1,n+1)%mod*2%mod<<endl;
        }
    }
    return 0;
}

### 回答1: Cube是一个支持各种STM32微控制器的软件平台,MPU6050是一款集成了三轴加速度计和三轴陀螺仪的传感器芯片,I2C是一种串行通信协议。 将这三者结合,即Cube MPU6050 I2C,意味着在STM32上使用MPU6050传感器时可以使用Cube软件平台进行开发,通过I2C协议与MPU6050进行通信。 MPU6050是一款十分常用的传感器芯片,可以应用于各种姿态控制场景,在机器人、无人机、智能家居等领域中占有重要地位。使用Cube软件平台可以方便地进行开发和调试,快速实现所需的功能。 使用I2C协议可以实现传感器和微控制器的有效通信,I2C协议具有传输速度快、线路简单、支持多从设备等优点,适用于许多低速数据传输场景。 总之,使用Cube MPU6050 I2C可以方便地在STM32上使用MPU6050传感器,快速实现各种姿态控制应用。 ### 回答2: Cube MPU6050 I2C是基于MPU6050传感器的I2C接口的一个方案。MPU6050是一种集成了三轴加速度计和三轴陀螺仪的惯性测量单元(IMU)。它使用数字界面通过I2C总线进行通信,并提供对所有六个轴的测量数据的访问。 Cube MPU6050 I2C的设计是为了简化应用程序的开发。它提供了一个图形化的配置工具,以帮助用户配置IMU来满足其应用需求。此外,该方案还包括一组预定义的软件库函数,可以轻松地集成到用户应用程序中。 由于其小巧的尺寸和低功耗,MPU6050常用于无人机、机器人、移动设备和医疗设备等应用中。Cube MPU6050 I2C的方案将大大简化这些应用程序的设计和开发,并提供对于IMU的快速、准确的数据访问。
评论 5
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值