/**
* Created by dcp on 2018/09/16.
*/
const readline = require('readline');
const rl = readline.createInterface({
input: process.stdin,
output: process.stdout
});
var inputArr = [];
rl.on('line', function (input) {
inputArr.push(input);
var nLine = +inputArr[0];//转化成数字类型
if (inputArr.length == (nLine + 1)) {
var arr = inputArr.slice(1);
for(var i=0;i<arr.length;i++){
hexie(arr[i])
}
inputArr = [];
}
});
function hexie(n) {
var sum=0;
var t=parseInt(n);
var arr=n.split('')
var re=arr.map(function (ietm) {
return ietm-0
})
for(var i=0;i<re.length;i++){
sum+=re[i];
}
sum=parseInt(sum)
if(t%sum===0){
console.log('Yes')
}else {
console.log('No')
}
}
/**
* Created by dcp on 2018/9/16.
*/
/**
* Created by dcp on 2018/09/16.
*/
var readline=require("readline");
var r1=readline.createInterface({
input:process.stdin,
output:process.stdout
});
//k控制输入行数
var k=3
//数组存储输入
var inputs=[];
r1.on("line",function(data){
inputs.push(data);
if(inputs.length==2) {
//字符串形式输出
var num0 = inputs[0].split(' ').toString()
//数组形式输出
var num1 = inputs[1].split(' ')
//将['2','3']转换成[2,3]
// var num2=inputs[2].split(' ')
// var mapResult=num2.map(function (item) {
// return item-0
// })
jiangu(num1)
}
});
function jiangu(arr) {
var cz=1,p=[];
for(var i=0;i<arr.length;i++){
if(arr[i]=='0'){
cz+=1;
}else {
p.push(cz)
cz=1;
}
}
p[0]=1;
var s=1;
for(var i=0;i<p.length;i++){
s*=p[i];
}
console.log(s)
}
//只ac0.4,完全做出来之后再更新
#include <iostream>
#include <fstream>
using namespace std;
int main() {
#ifdef DEBUG
ifstream cin("../Tencent/data4.in");
if (!cin.is_open()) {
cout << "open error" << endl;
exit(0);
}
#endif
string S, P;
cin >> S >> P;
int lenP = P.length();
int lenS = S.length();
int idx = lenP;
for (int i = 1, j = lenP - 1; i <= j; ++i, --j) {
if (P.substr(0, i) == P.substr(j, lenP - j)) {
idx = min(idx, j);
}
}
int maxLen = 0;
int preIdx = 0;
int res = 0;
for (int i = 0; i < lenS;) {
if (S.substr(i, lenP) == P) {
maxLen = max(maxLen, i + lenP - preIdx);
i += idx;
} else {
// i+=lenP;
++i;
preIdx = i;
res += maxLen * maxLen;
maxLen = 0;
}
}
res += maxLen * maxLen;
cout << res << endl;
return 0;
}